Go SSA Mem Type

What is the purpose of mem type in Golang’s SSA?
This article gives me an intro to Golang’s SSA, but I don’t understand the “Memory types” part. It seems there is a special type in the SSA called memory. From the article, this memory type seems useful to maintain the ordering of Store command like the example below:

// *a = 3
// *b = *a
v10 = Store <mem> {int} v6 v8 v1
v14 = Store <mem> {int} v7 v8 v10

But, I don’t get why we need mem type.

  • Can’t Go infer the ordering constraint by itself (without the help of mem type)? I believe LLVM can do this. And they have a special fencing mechanism to prevent reordering if we want to.
  • And why the ordering in above example matters? From the SSA it seems we store v8 to v6 and then store v8 to v7, it doesn’t look like there is an ordering dependency there (from the SSA point of view).
  • Is there any order purpose of the mem type? It feels weird to call it “mem” when the purpose is just for ordering.