jitao09423024
jitao09423024

Reputation: 31

LLVM IR: struct alignment is wrong

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!

Upvotes: 1

Views: 162

Answers (1)

jitao09423024
jitao09423024

Reputation: 31

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.

Upvotes: 2

Related Questions