Bill Wendling | 4c3b514d | 2013-09-11 19:06:04 +0000 | [diff] [blame] | 1 | ; 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 Lopes | 27de9b0 | 2014-12-08 18:18:32 +0000 | [diff] [blame] | 3 | ; RUN: | llvm-objdump -triple x86_64-apple-darwin11 -unwind-info - \ |
Bill Wendling | 58e2d3d | 2013-09-09 02:37:14 +0000 | [diff] [blame] | 4 | ; RUN: | FileCheck -check-prefix=CU %s |
Bill Wendling | 4c3b514d | 2013-09-11 19:06:04 +0000 | [diff] [blame] | 5 | ; RUN: llc < %s -disable-fp-elim -mtriple x86_64-apple-darwin11 -mcpu corei7 \ |
Bill Wendling | 19ba3c9 | 2013-09-09 20:29:32 +0000 | [diff] [blame] | 6 | ; RUN: | llvm-mc -triple x86_64-apple-darwin11 -filetype=obj -o - \ |
Bruno Cardoso Lopes | 27de9b0 | 2014-12-08 18:18:32 +0000 | [diff] [blame] | 7 | ; RUN: | llvm-objdump -triple x86_64-apple-darwin11 -unwind-info - \ |
Bill Wendling | 93158ff | 2013-09-09 20:10:54 +0000 | [diff] [blame] | 8 | ; RUN: | FileCheck -check-prefix=FROM-ASM %s |
Bill Wendling | 07fe235 | 2013-05-09 20:10:38 +0000 | [diff] [blame] | 9 | |
Bruno Cardoso Lopes | 27de9b0 | 2014-12-08 18:18:32 +0000 | [diff] [blame] | 10 | ; 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 Wendling | 07fe235 | 2013-05-09 20:10:38 +0000 | [diff] [blame] | 18 | %ty = type { i8* } |
| 19 | |
| 20 | @gv = external global i32 |
| 21 | |
| 22 | ; This is aligning the stack with a push of a random register. |
Bill Wendling | 58e2d3d | 2013-09-09 02:37:14 +0000 | [diff] [blame] | 23 | ; ASM: pushq %rax |
Bill Wendling | 07fe235 | 2013-05-09 20:10:38 +0000 | [diff] [blame] | 24 | |
| 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 Wendling | 93158ff | 2013-09-09 20:10:54 +0000 | [diff] [blame] | 27 | |
Bruno Cardoso Lopes | 27de9b0 | 2014-12-08 18:18:32 +0000 | [diff] [blame] | 28 | ; 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 Wendling | 07fe235 | 2013-05-09 20:10:38 +0000 | [diff] [blame] | 33 | |
Bruno Cardoso Lopes | 27de9b0 | 2014-12-08 18:18:32 +0000 | [diff] [blame] | 34 | ; 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 Wendling | 93158ff | 2013-09-09 20:10:54 +0000 | [diff] [blame] | 39 | |
Bruno Cardoso Lopes | 27de9b0 | 2014-12-08 18:18:32 +0000 | [diff] [blame] | 40 | define i8* @test0(i64 %size) { |
Bill Wendling | 07fe235 | 2013-05-09 20:10:38 +0000 | [diff] [blame] | 41 | %addr = alloca i64, align 8 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 42 | %tmp20 = load i32, i32* @gv, align 4 |
Bill Wendling | 07fe235 | 2013-05-09 20:10:38 +0000 | [diff] [blame] | 43 | %tmp21 = call i32 @bar() |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 44 | %tmp25 = load i64, i64* %addr, align 8 |
Bill Wendling | 07fe235 | 2013-05-09 20:10:38 +0000 | [diff] [blame] | 45 | %tmp26 = inttoptr i64 %tmp25 to %ty* |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 46 | %tmp29 = getelementptr inbounds %ty, %ty* %tmp26, i64 0, i32 0 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 47 | %tmp34 = load i8*, i8** %tmp29, align 8 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 48 | %tmp35 = getelementptr inbounds i8, i8* %tmp34, i64 %size |
Bill Wendling | 07fe235 | 2013-05-09 20:10:38 +0000 | [diff] [blame] | 49 | store i8* %tmp35, i8** %tmp29, align 8 |
| 50 | ret i8* null |
| 51 | } |
| 52 | |
| 53 | declare i32 @bar() |
Bruno Cardoso Lopes | 27de9b0 | 2014-12-08 18:18:32 +0000 | [diff] [blame] | 54 | |
| 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 | |
| 62 | declare 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 | |
| 77 | define void @test1(%class.ImageLoader* %image) optsize ssp uwtable { |
| 78 | entry: |
| 79 | br label %for.cond1.preheader |
| 80 | |
| 81 | for.cond1.preheader: ; preds = %for.inc10, %entry |
| 82 | %p.019 = phi %"struct.dyld::MappedRanges"* [ @G1, %entry ], [ %1, %for.inc10 ] |
| 83 | br label %for.body3 |
| 84 | |
| 85 | for.body3: ; preds = %for.inc, %for.cond1.preheader |
| 86 | %indvars.iv = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next, %for.inc ] |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 87 | %image4 = getelementptr inbounds %"struct.dyld::MappedRanges", %"struct.dyld::MappedRanges"* %p.019, i64 0, i32 0, i64 %indvars.iv, i32 0 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 88 | %0 = load %class.ImageLoader*, %class.ImageLoader** %image4, align 8 |
Bruno Cardoso Lopes | 27de9b0 | 2014-12-08 18:18:32 +0000 | [diff] [blame] | 89 | %cmp5 = icmp eq %class.ImageLoader* %0, %image |
| 90 | br i1 %cmp5, label %if.then, label %for.inc |
| 91 | |
| 92 | if.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 | |
| 97 | for.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 | |
| 103 | for.inc10: ; preds = %for.inc |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 104 | %next = getelementptr inbounds %"struct.dyld::MappedRanges", %"struct.dyld::MappedRanges"* %p.019, i64 0, i32 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 105 | %1 = load %"struct.dyld::MappedRanges"*, %"struct.dyld::MappedRanges"** %next, align 8 |
Bruno Cardoso Lopes | 27de9b0 | 2014-12-08 18:18:32 +0000 | [diff] [blame] | 106 | %cmp = icmp eq %"struct.dyld::MappedRanges"* %1, null |
| 107 | br i1 %cmp, label %for.end11, label %for.cond1.preheader |
| 108 | |
| 109 | for.end11: ; preds = %for.inc10 |
| 110 | ret void |
| 111 | } |