xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/packed_struct.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86 > %t
2*9880d681SAndroid Build Coastguard Worker; RUN: grep foos+5 %t
3*9880d681SAndroid Build Coastguard Worker; RUN: grep foos+1 %t
4*9880d681SAndroid Build Coastguard Worker; RUN: grep foos+9 %t
5*9880d681SAndroid Build Coastguard Worker; RUN: grep bara+19 %t
6*9880d681SAndroid Build Coastguard Worker; RUN: grep bara+4 %t
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Worker; make sure we compute the correct offset for a packed structure
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Worker;Note: codegen for this could change rendering the above checks wrong
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-p:32:32"
13*9880d681SAndroid Build Coastguard Workertarget triple = "i686-pc-linux-gnu"
14*9880d681SAndroid Build Coastguard Worker	%struct.anon = type <{ i8, i32, i32, i32 }>
15*9880d681SAndroid Build Coastguard Worker@foos = external global %struct.anon		; <%struct.anon*> [#uses=3]
16*9880d681SAndroid Build Coastguard Worker@bara = weak global [4 x <{ i32, i8 }>] zeroinitializer		; <[4 x <{ i32, i8 }>]*> [#uses=2]
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Workerdefine i32 @foo() nounwind {
19*9880d681SAndroid Build Coastguard Workerentry:
20*9880d681SAndroid Build Coastguard Worker	%tmp = load i32, i32* getelementptr (%struct.anon, %struct.anon* @foos, i32 0, i32 1)		; <i32> [#uses=1]
21*9880d681SAndroid Build Coastguard Worker	%tmp3 = load i32, i32* getelementptr (%struct.anon, %struct.anon* @foos, i32 0, i32 2)		; <i32> [#uses=1]
22*9880d681SAndroid Build Coastguard Worker	%tmp6 = load i32, i32* getelementptr (%struct.anon, %struct.anon* @foos, i32 0, i32 3)		; <i32> [#uses=1]
23*9880d681SAndroid Build Coastguard Worker	%tmp4 = add i32 %tmp3, %tmp		; <i32> [#uses=1]
24*9880d681SAndroid Build Coastguard Worker	%tmp7 = add i32 %tmp4, %tmp6		; <i32> [#uses=1]
25*9880d681SAndroid Build Coastguard Worker	ret i32 %tmp7
26*9880d681SAndroid Build Coastguard Worker}
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Workerdefine i8 @bar() nounwind {
29*9880d681SAndroid Build Coastguard Workerentry:
30*9880d681SAndroid Build Coastguard Worker	%tmp = load i8, i8* getelementptr ([4 x <{ i32, i8 }>], [4 x <{ i32, i8 }>]* @bara, i32 0, i32 0, i32 1)		; <i8> [#uses=1]
31*9880d681SAndroid Build Coastguard Worker	%tmp4 = load i8, i8* getelementptr ([4 x <{ i32, i8 }>], [4 x <{ i32, i8 }>]* @bara, i32 0, i32 3, i32 1)		; <i8> [#uses=1]
32*9880d681SAndroid Build Coastguard Worker	%tmp5 = add i8 %tmp4, %tmp		; <i8> [#uses=1]
33*9880d681SAndroid Build Coastguard Worker	ret i8 %tmp5
34*9880d681SAndroid Build Coastguard Worker}
35