Offsets in TBAA Access Tags

Dear LLVMers,

I’m following the TBAA section from the LLVM

Language Reference Manual, and I found a minor
detail in the offsets in the access tags.

For example:

void f(struct Outer* outer, struct Inner* inner, float* f, int* i, char* c) {
  outer->f = 0;            // tag0: (OuterStructTy, FloatScalarTy, 0)
  outer->inner_a.i = 0;    // tag1: (OuterStructTy, IntScalarTy, 12)
  outer->inner_a.f = 0.0;  // tag2: (OuterStructTy, FloatScalarTy, 16)
  *f = 0.0;                // tag3: (FloatScalarTy, FloatScalarTy, 0)
}

When this program is compiled to the IR, the
offsets in tag1 and tag2 are actually 4 bytes more
than the indicated in the text. (x86_64 architecture)

store i32 0, i32* %i2, align 8, !dbg !46, !tbaa !47
!47 = !{!38, !44, i64 16} (tag1)

store float 0.000000e+00, float* %f4, align 4, !dbg !49, !tbaa !50
!50 = !{!38, !39, i64 20} (tag2)

Is this an error in the manual, or is just some padding
within structs Outer and Inner that are yielding
such a difference?

Best regards,

Hi Jose,

The langref is correct for a 32-bit architecture, but indeed forgets to mention that in the example.

Also see: https://www.godbolt.org/z/PseehvTdf

For a 64-bit architecture, the inner_a is at a 16-byte boundary. (Just omit the ‘-m32’ in the godbolt link)

Greetings,

Jeroen Dobbelaere