blob: f8266a10cfb5ab052be376997ed36f9aed7f16c1 [file] [log] [blame]
Bill Wendling4c3b514d2013-09-11 19:06:04 +00001; RUN: llc < %s -disable-fp-elim -mtriple x86_64-apple-darwin11 -mcpu corei7 | FileCheck -check-prefix=ASM %s
2; RUN: llc < %s -disable-fp-elim -mtriple x86_64-apple-darwin11 -mcpu corei7 -filetype=obj -o - \
Bruno Cardoso Lopes27de9b02014-12-08 18:18:32 +00003; RUN: | llvm-objdump -triple x86_64-apple-darwin11 -unwind-info - \
Bill Wendling58e2d3d2013-09-09 02:37:14 +00004; RUN: | FileCheck -check-prefix=CU %s
Bill Wendling4c3b514d2013-09-11 19:06:04 +00005; RUN: llc < %s -disable-fp-elim -mtriple x86_64-apple-darwin11 -mcpu corei7 \
Bill Wendling19ba3c92013-09-09 20:29:32 +00006; RUN: | llvm-mc -triple x86_64-apple-darwin11 -filetype=obj -o - \
Bruno Cardoso Lopes27de9b02014-12-08 18:18:32 +00007; RUN: | llvm-objdump -triple x86_64-apple-darwin11 -unwind-info - \
Bill Wendling93158ff2013-09-09 20:10:54 +00008; RUN: | FileCheck -check-prefix=FROM-ASM %s
Bill Wendling07fe2352013-05-09 20:10:38 +00009
Bruno Cardoso Lopes27de9b02014-12-08 18:18:32 +000010; RUN: llc < %s -mtriple x86_64-apple-macosx10.8.0 -mcpu corei7 -filetype=obj -o - \
11; RUN: | llvm-objdump -triple x86_64-apple-macosx10.8.0 -unwind-info - \
12; RUN: | FileCheck -check-prefix=NOFP-CU %s
13; RUN: llc < %s -mtriple x86_64-apple-darwin11 -mcpu corei7 \
14; RUN: | llvm-mc -triple x86_64-apple-darwin11 -filetype=obj -o - \
15; RUN: | llvm-objdump -triple x86_64-apple-darwin11 -unwind-info - \
16; RUN: | FileCheck -check-prefix=NOFP-FROM-ASM %s
17
Bill Wendling07fe2352013-05-09 20:10:38 +000018%ty = type { i8* }
19
20@gv = external global i32
21
22; This is aligning the stack with a push of a random register.
Bill Wendling58e2d3d2013-09-09 02:37:14 +000023; ASM: pushq %rax
Bill Wendling07fe2352013-05-09 20:10:38 +000024
25; Even though we can't encode %rax into the compact unwind, We still want to be
26; able to generate a compact unwind encoding in this particular case.
Bill Wendling93158ff2013-09-09 20:10:54 +000027
Bruno Cardoso Lopes27de9b02014-12-08 18:18:32 +000028; CU: Contents of __compact_unwind section:
29; CU-NEXT: Entry at offset 0x0:
30; CU-NEXT: start: 0x0 _test0
31; CU-NEXT: length: 0x1e
32; CU-NEXT: compact encoding: 0x01010001
Bill Wendling07fe2352013-05-09 20:10:38 +000033
Bruno Cardoso Lopes27de9b02014-12-08 18:18:32 +000034; FROM-ASM: Contents of __compact_unwind section:
35; FROM-ASM-NEXT: Entry at offset 0x0:
36; FROM-ASM-NEXT: start: 0x0 _test0
37; FROM-ASM-NEXT: length: 0x1e
38; FROM-ASM-NEXT: compact encoding: 0x01010001
Bill Wendling93158ff2013-09-09 20:10:54 +000039
Bruno Cardoso Lopes27de9b02014-12-08 18:18:32 +000040define i8* @test0(i64 %size) {
Bill Wendling07fe2352013-05-09 20:10:38 +000041 %addr = alloca i64, align 8
David Blaikiea79ac142015-02-27 21:17:42 +000042 %tmp20 = load i32, i32* @gv, align 4
Bill Wendling07fe2352013-05-09 20:10:38 +000043 %tmp21 = call i32 @bar()
David Blaikiea79ac142015-02-27 21:17:42 +000044 %tmp25 = load i64, i64* %addr, align 8
Bill Wendling07fe2352013-05-09 20:10:38 +000045 %tmp26 = inttoptr i64 %tmp25 to %ty*
David Blaikie79e6c742015-02-27 19:29:02 +000046 %tmp29 = getelementptr inbounds %ty, %ty* %tmp26, i64 0, i32 0
David Blaikiea79ac142015-02-27 21:17:42 +000047 %tmp34 = load i8*, i8** %tmp29, align 8
David Blaikie79e6c742015-02-27 19:29:02 +000048 %tmp35 = getelementptr inbounds i8, i8* %tmp34, i64 %size
Bill Wendling07fe2352013-05-09 20:10:38 +000049 store i8* %tmp35, i8** %tmp29, align 8
50 ret i8* null
51}
52
53declare i32 @bar()
Bruno Cardoso Lopes27de9b02014-12-08 18:18:32 +000054
55%"struct.dyld::MappedRanges" = type { [400 x %struct.anon], %"struct.dyld::MappedRanges"* }
56%struct.anon = type { %class.ImageLoader*, i64, i64 }
57%class.ImageLoader = type { i32 (...)**, i8*, i8*, i32, i64, i64, i32, i32, %"struct.ImageLoader::recursive_lock"*, i16, i16, [4 x i8] }
58%"struct.ImageLoader::recursive_lock" = type { i32, i32 }
59
60@G1 = external hidden global %"struct.dyld::MappedRanges", align 8
61
62declare void @OSMemoryBarrier() optsize
63
64; Test the code below uses UNWIND_X86_64_MODE_STACK_IMMD compact unwind
65; encoding.
66
67; NOFP-CU: Entry at offset 0x20:
68; NOFP-CU-NEXT: start: 0x1d _test1
69; NOFP-CU-NEXT: length: 0x42
70; NOFP-CU-NEXT: compact encoding: 0x02040c0a
71
72; NOFP-FROM-ASM: Entry at offset 0x20:
73; NOFP-FROM-ASM-NEXT: start: 0x1d _test1
74; NOFP-FROM-ASM-NEXT: length: 0x42
75; NOFP-FROM-ASM-NEXT: compact encoding: 0x02040c0a
76
77define void @test1(%class.ImageLoader* %image) optsize ssp uwtable {
78entry:
79 br label %for.cond1.preheader
80
81for.cond1.preheader: ; preds = %for.inc10, %entry
82 %p.019 = phi %"struct.dyld::MappedRanges"* [ @G1, %entry ], [ %1, %for.inc10 ]
83 br label %for.body3
84
85for.body3: ; preds = %for.inc, %for.cond1.preheader
86 %indvars.iv = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next, %for.inc ]
David Blaikie79e6c742015-02-27 19:29:02 +000087 %image4 = getelementptr inbounds %"struct.dyld::MappedRanges", %"struct.dyld::MappedRanges"* %p.019, i64 0, i32 0, i64 %indvars.iv, i32 0
David Blaikiea79ac142015-02-27 21:17:42 +000088 %0 = load %class.ImageLoader*, %class.ImageLoader** %image4, align 8
Bruno Cardoso Lopes27de9b02014-12-08 18:18:32 +000089 %cmp5 = icmp eq %class.ImageLoader* %0, %image
90 br i1 %cmp5, label %if.then, label %for.inc
91
92if.then: ; preds = %for.body3
93 tail call void @OSMemoryBarrier() optsize
94 store %class.ImageLoader* null, %class.ImageLoader** %image4, align 8
95 br label %for.inc
96
97for.inc: ; preds = %if.then, %for.body3
98 %indvars.iv.next = add i64 %indvars.iv, 1
99 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
100 %exitcond = icmp eq i32 %lftr.wideiv, 400
101 br i1 %exitcond, label %for.inc10, label %for.body3
102
103for.inc10: ; preds = %for.inc
David Blaikie79e6c742015-02-27 19:29:02 +0000104 %next = getelementptr inbounds %"struct.dyld::MappedRanges", %"struct.dyld::MappedRanges"* %p.019, i64 0, i32 1
David Blaikiea79ac142015-02-27 21:17:42 +0000105 %1 = load %"struct.dyld::MappedRanges"*, %"struct.dyld::MappedRanges"** %next, align 8
Bruno Cardoso Lopes27de9b02014-12-08 18:18:32 +0000106 %cmp = icmp eq %"struct.dyld::MappedRanges"* %1, null
107 br i1 %cmp, label %for.end11, label %for.cond1.preheader
108
109for.end11: ; preds = %for.inc10
110 ret void
111}