1; RUN: llc < %s -frame-pointer=all -mtriple x86_64-apple-darwin11 -mcpu corei7 -emit-compact-unwind-non-canonical=true | FileCheck -check-prefix=ASM %s 2; RUN: llc < %s -frame-pointer=all -mtriple x86_64-apple-darwin11 -mcpu corei7 -filetype=obj -emit-compact-unwind-non-canonical=true -o - \ 3; RUN: | llvm-objdump --triple=x86_64-apple-darwin11 --unwind-info - \ 4; RUN: | FileCheck -check-prefix=CU %s 5; RUN: llc < %s -frame-pointer=all -mtriple x86_64-apple-darwin11 -mcpu corei7 -emit-compact-unwind-non-canonical=true \ 6; RUN: | llvm-mc -triple x86_64-apple-darwin11 -filetype=obj -emit-compact-unwind-non-canonical=true -o - \ 7; RUN: | llvm-objdump --triple=x86_64-apple-darwin11 --unwind-info - \ 8; RUN: | FileCheck -check-prefix=FROM-ASM %s 9 10; RUN: llc < %s -mtriple x86_64-apple-macosx10.8.0 -mcpu corei7 -filetype=obj -emit-compact-unwind-non-canonical=true -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 -emit-compact-unwind-non-canonical=true -o - \ 15; RUN: | llvm-objdump --triple=x86_64-apple-darwin11 --unwind-info - \ 16; RUN: | FileCheck -check-prefix=NOFP-FROM-ASM %s 17 18%ty = type { ptr } 19 20@gv = external global i32 21 22; This is aligning the stack with a push of a random register. 23; ASM: pushq %rax 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. 27 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 33 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 39 40define ptr @test0(i64 %size) { 41 %addr = alloca i64, align 8 42 %tmp20 = load i32, ptr @gv, align 4 43 %tmp21 = call i32 @bar() 44 %tmp25 = load i64, ptr %addr, align 8 45 %tmp26 = inttoptr i64 %tmp25 to ptr 46 %tmp34 = load ptr, ptr %tmp26, align 8 47 %tmp35 = getelementptr inbounds i8, ptr %tmp34, i64 %size 48 store ptr %tmp35, ptr %tmp26, align 8 49 ret ptr null 50} 51 52declare i32 @bar() 53 54%"struct.dyld::MappedRanges" = type { [400 x %struct.anon], ptr } 55%struct.anon = type { ptr, i64, i64 } 56%class.ImageLoader = type { ptr, ptr, ptr, i32, i64, i64, i32, i32, ptr, i16, i16, [4 x i8] } 57%"struct.ImageLoader::recursive_lock" = type { i32, i32 } 58 59@G1 = external hidden global %"struct.dyld::MappedRanges", align 8 60 61declare void @OSMemoryBarrier() optsize 62 63; Test the code below uses UNWIND_X86_64_MODE_STACK_IMMD compact unwind 64; encoding. 65 66; NOFP-CU: Entry at offset 0x20: 67; NOFP-CU-NEXT: start: 0x1d _test1 68; NOFP-CU-NEXT: length: 0x44 69; NOFP-CU-NEXT: compact encoding: 0x02040c0a 70 71; NOFP-FROM-ASM: Entry at offset 0x20: 72; NOFP-FROM-ASM-NEXT: start: 0x1d _test1 73; NOFP-FROM-ASM-NEXT: length: 0x44 74; NOFP-FROM-ASM-NEXT: compact encoding: 0x02040c0a 75 76define void @test1(ptr %image) optsize ssp uwtable { 77entry: 78 br label %for.cond1.preheader 79 80for.cond1.preheader: ; preds = %for.inc10, %entry 81 %p.019 = phi ptr [ @G1, %entry ], [ %1, %for.inc10 ] 82 br label %for.body3 83 84for.body3: ; preds = %for.inc, %for.cond1.preheader 85 %indvars.iv = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next, %for.inc ] 86 %image4 = getelementptr inbounds %"struct.dyld::MappedRanges", ptr %p.019, i64 0, i32 0, i64 %indvars.iv, i32 0 87 %0 = load ptr, ptr %image4, align 8 88 %cmp5 = icmp eq ptr %0, %image 89 br i1 %cmp5, label %if.then, label %for.inc 90 91if.then: ; preds = %for.body3 92 tail call void @OSMemoryBarrier() optsize 93 store ptr null, ptr %image4, align 8 94 br label %for.inc 95 96for.inc: ; preds = %if.then, %for.body3 97 %indvars.iv.next = add i64 %indvars.iv, 1 98 %lftr.wideiv = trunc i64 %indvars.iv.next to i32 99 %exitcond = icmp eq i32 %lftr.wideiv, 400 100 br i1 %exitcond, label %for.inc10, label %for.body3 101 102for.inc10: ; preds = %for.inc 103 %next = getelementptr inbounds %"struct.dyld::MappedRanges", ptr %p.019, i64 0, i32 1 104 %1 = load ptr, ptr %next, align 8 105 %cmp = icmp eq ptr %1, null 106 br i1 %cmp, label %for.end11, label %for.cond1.preheader 107 108for.end11: ; preds = %for.inc10 109 ret void 110} 111