0

I'm new to llvm framework and using llvm to generate jit code. But the code generated about struct is a bit problematic:

`

source_filename = "test1"
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
target triple = "arm64-apple-macosx12.0.0"

%Coordinate = type { i32, i32 }

define i32 @main() {
entry:
  %0 = call %Coordinate @PSnative_create_coordinate(i32 5, i32 6)
  %coordinate1 = alloca %Coordinate, align 8
...

I think the struct alignment of alloc should be 4, but here is 8.

the alloc IR is emitted by CreateAlloca()

Very very grateful if anyone can tell me what is wrong.

Thanks!

  • Immediately after CreateAlloca is called, does it already have the align? Or is that being added by an optimization pass? As far as I understand, it's never _wrong_ to overalign an allocation, though I don't see why LLVM would do so in this case. – Nick Lewycky Dec 22 '22 at 21:39
  • 1
    @NickLewycky Thank you. It seems that this is the default alignment. I have changed it to 4 by modifying the data layout of the module. – jitao09423024 Dec 23 '22 at 06:39

1 Answers1

1

It seems that the align 8 is the default alignment of aggregate type for my architecture and it could be changed to 4 by modifying the layout of the module.