[llvm-dev] Offsets in TBAA Access Tags

Jeroen Dobbelaere via llvm-dev llvm-dev at lists.llvm.org
Mon Apr 26 07:46:30 PDT 2021


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



From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of José Wesley Magalhães via llvm-dev
Sent: Monday, April 26, 2021 15:43
To: llvm-dev <llvm-dev at lists.llvm.org>
Subject: [llvm-dev] 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,

José Wesley de Souza Magalhães
MSc Student in Computer Science
Belo Horizonte/MG - Brazil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210426/b43b263f/attachment.html>


More information about the llvm-dev mailing list