1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-- -relocation-model=static | FileCheck %s
4 @X = external dso_local global [0 x i32]
6 define void @foo() nounwind {
8 ; CHECK: # %bb.0: # %entry
9 ; CHECK-NEXT: pushl %eax
10 ; CHECK-NEXT: movl %esp, %eax
11 ; CHECK-NEXT: pushl %eax
12 ; CHECK-NEXT: calll frob@PLT
13 ; CHECK-NEXT: addl $4, %esp
14 ; CHECK-NEXT: leal X(%esp), %eax
15 ; CHECK-NEXT: pushl %eax
16 ; CHECK-NEXT: calll borf@PLT
17 ; CHECK-NEXT: addl $4, %esp
18 ; CHECK-NEXT: popl %eax
22 call void @frob(i32* %Y) nounwind
23 %Y3 = bitcast i32* %Y to i8*
24 %ctg2 = getelementptr i8, i8* %Y3, i32 ptrtoint ([0 x i32]* @X to i32)
25 %0 = ptrtoint i8* %ctg2 to i32
26 call void @borf(i32 %0) nounwind
30 define void @bar(i32 %i) nounwind {
32 ; CHECK: # %bb.0: # %entry
33 ; CHECK-NEXT: pushl %esi
34 ; CHECK-NEXT: subl $40, %esp
35 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %esi
36 ; CHECK-NEXT: movl %esp, %eax
37 ; CHECK-NEXT: pushl %eax
38 ; CHECK-NEXT: calll frob@PLT
39 ; CHECK-NEXT: addl $4, %esp
40 ; CHECK-NEXT: leal X(%esp,%esi,4), %eax
41 ; CHECK-NEXT: pushl %eax
42 ; CHECK-NEXT: calll borf@PLT
43 ; CHECK-NEXT: addl $44, %esp
44 ; CHECK-NEXT: popl %esi
47 %Y = alloca [10 x i32]
48 %0 = getelementptr [10 x i32], [10 x i32]* %Y, i32 0, i32 0
49 call void @frob(i32* %0) nounwind
50 %1 = getelementptr [0 x i32], [0 x i32]* @X, i32 0, i32 %i
51 %2 = getelementptr [10 x i32], [10 x i32]* %Y, i32 0, i32 0
52 %3 = ptrtoint i32* %2 to i32
53 %4 = bitcast i32* %1 to i8*
54 %ctg2 = getelementptr i8, i8* %4, i32 %3
55 %5 = ptrtoint i8* %ctg2 to i32
56 call void @borf(i32 %5) nounwind
60 declare void @frob(i32*)
62 declare void @borf(i32)