xref: /llvm-project/llvm/test/ExecutionEngine/Orc/global-variable-alignment.ll (revision 1fb99dedd711c343f01a959f1a843cc92a3002b0)
1; Check that lli respects alignment on global variables.
2;
3; Returns ((uint32_t)&B & 0x7) - A + C. Variables A and C have byte-alignment,
4; and are intended to increase the chance of misalignment, but don't contribute
5; to the result, since they have the same initial value.
6;
7; A failure may indicate a problem with alignment handling in the JIT linker or
8; JIT memory manager.
9;
10; RUN: %lli %s
11
12@A = internal global i8 1, align 1
13@B = global i64 1, align 8
14@C = internal global i8 1, align 1
15
16define i32 @main(i32 %argc, i8** %argv) {
17entry:
18  %0 = ptrtoint i8* @B to i32
19  %1 = and i32 %0, 7
20  %2 = load i8, i8* @A
21  %3 = zext i8 %2 to i32
22  %4 = add i32 %1, %3
23  %5 = load i8, i8* @C
24  %6 = zext i8 %5 to i32
25  %7 = sub i32 %4, %6
26  ret i32 %7
27}
28