Jason Yu
Jason Yu

Reputation: 2038

The meaning of 'store {} {}, {}* %p' in llvm-ir?

I know that the store instruction is used to store data into memory, but what does the following piece of llvm-ir code mean? Where you can see lots of empty "{}" structures here.

; CHECK:      Function: foo:
; CHECK-NEXT:   NoAlias: {}* %p, {}* %q

define void @foo({}* %p, {}* %q) {
  store {} {}, {}* %p
  store {} {}, {}* %q
  ret void
}

FYI: https://github.com/llvm-mirror/llvm/blob/master/test/Analysis/CFLAliasAnalysis/Steensgaard/empty.ll

Upvotes: 0

Views: 307

Answers (1)

arnt
arnt

Reputation: 9685

Each of those two stores a pointer into RAM. The pointer points to a zero-byte structure, but that doesn't affect the operation of storing the pointer.

As to why, it's test code. Do you know the joke about the tester who walks into a bar and orders zero beers? Structs can contain zero fields (and sometimes do, e.g. when each field has been separately determined to be redundant and optimised away) so the compiler needs to handle empty structs, and therefore tests contain empty structs.

Upvotes: 5

Related Questions