1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -disable-fp-elim -mtriple x86_64-apple-darwin11 -mcpu corei7 | FileCheck -check-prefix=ASM %s 2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -disable-fp-elim -mtriple x86_64-apple-darwin11 -mcpu corei7 -filetype=obj -o - \ 3*9880d681SAndroid Build Coastguard Worker; RUN: | llvm-objdump -triple x86_64-apple-darwin11 -unwind-info - \ 4*9880d681SAndroid Build Coastguard Worker; RUN: | FileCheck -check-prefix=CU %s 5*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -disable-fp-elim -mtriple x86_64-apple-darwin11 -mcpu corei7 \ 6*9880d681SAndroid Build Coastguard Worker; RUN: | llvm-mc -triple x86_64-apple-darwin11 -filetype=obj -o - \ 7*9880d681SAndroid Build Coastguard Worker; RUN: | llvm-objdump -triple x86_64-apple-darwin11 -unwind-info - \ 8*9880d681SAndroid Build Coastguard Worker; RUN: | FileCheck -check-prefix=FROM-ASM %s 9*9880d681SAndroid Build Coastguard Worker 10*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple x86_64-apple-macosx10.8.0 -mcpu corei7 -filetype=obj -o - \ 11*9880d681SAndroid Build Coastguard Worker; RUN: | llvm-objdump -triple x86_64-apple-macosx10.8.0 -unwind-info - \ 12*9880d681SAndroid Build Coastguard Worker; RUN: | FileCheck -check-prefix=NOFP-CU %s 13*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple x86_64-apple-darwin11 -mcpu corei7 \ 14*9880d681SAndroid Build Coastguard Worker; RUN: | llvm-mc -triple x86_64-apple-darwin11 -filetype=obj -o - \ 15*9880d681SAndroid Build Coastguard Worker; RUN: | llvm-objdump -triple x86_64-apple-darwin11 -unwind-info - \ 16*9880d681SAndroid Build Coastguard Worker; RUN: | FileCheck -check-prefix=NOFP-FROM-ASM %s 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker%ty = type { i8* } 19*9880d681SAndroid Build Coastguard Worker 20*9880d681SAndroid Build Coastguard Worker@gv = external global i32 21*9880d681SAndroid Build Coastguard Worker 22*9880d681SAndroid Build Coastguard Worker; This is aligning the stack with a push of a random register. 23*9880d681SAndroid Build Coastguard Worker; ASM: pushq %rax 24*9880d681SAndroid Build Coastguard Worker 25*9880d681SAndroid Build Coastguard Worker; Even though we can't encode %rax into the compact unwind, We still want to be 26*9880d681SAndroid Build Coastguard Worker; able to generate a compact unwind encoding in this particular case. 27*9880d681SAndroid Build Coastguard Worker 28*9880d681SAndroid Build Coastguard Worker; CU: Contents of __compact_unwind section: 29*9880d681SAndroid Build Coastguard Worker; CU-NEXT: Entry at offset 0x0: 30*9880d681SAndroid Build Coastguard Worker; CU-NEXT: start: 0x0 _test0 31*9880d681SAndroid Build Coastguard Worker; CU-NEXT: length: 0x1e 32*9880d681SAndroid Build Coastguard Worker; CU-NEXT: compact encoding: 0x01010001 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Worker; FROM-ASM: Contents of __compact_unwind section: 35*9880d681SAndroid Build Coastguard Worker; FROM-ASM-NEXT: Entry at offset 0x0: 36*9880d681SAndroid Build Coastguard Worker; FROM-ASM-NEXT: start: 0x0 _test0 37*9880d681SAndroid Build Coastguard Worker; FROM-ASM-NEXT: length: 0x1e 38*9880d681SAndroid Build Coastguard Worker; FROM-ASM-NEXT: compact encoding: 0x01010001 39*9880d681SAndroid Build Coastguard Worker 40*9880d681SAndroid Build Coastguard Workerdefine i8* @test0(i64 %size) { 41*9880d681SAndroid Build Coastguard Worker %addr = alloca i64, align 8 42*9880d681SAndroid Build Coastguard Worker %tmp20 = load i32, i32* @gv, align 4 43*9880d681SAndroid Build Coastguard Worker %tmp21 = call i32 @bar() 44*9880d681SAndroid Build Coastguard Worker %tmp25 = load i64, i64* %addr, align 8 45*9880d681SAndroid Build Coastguard Worker %tmp26 = inttoptr i64 %tmp25 to %ty* 46*9880d681SAndroid Build Coastguard Worker %tmp29 = getelementptr inbounds %ty, %ty* %tmp26, i64 0, i32 0 47*9880d681SAndroid Build Coastguard Worker %tmp34 = load i8*, i8** %tmp29, align 8 48*9880d681SAndroid Build Coastguard Worker %tmp35 = getelementptr inbounds i8, i8* %tmp34, i64 %size 49*9880d681SAndroid Build Coastguard Worker store i8* %tmp35, i8** %tmp29, align 8 50*9880d681SAndroid Build Coastguard Worker ret i8* null 51*9880d681SAndroid Build Coastguard Worker} 52*9880d681SAndroid Build Coastguard Worker 53*9880d681SAndroid Build Coastguard Workerdeclare i32 @bar() 54*9880d681SAndroid Build Coastguard Worker 55*9880d681SAndroid Build Coastguard Worker%"struct.dyld::MappedRanges" = type { [400 x %struct.anon], %"struct.dyld::MappedRanges"* } 56*9880d681SAndroid Build Coastguard Worker%struct.anon = type { %class.ImageLoader*, i64, i64 } 57*9880d681SAndroid Build Coastguard Worker%class.ImageLoader = type { i32 (...)**, i8*, i8*, i32, i64, i64, i32, i32, %"struct.ImageLoader::recursive_lock"*, i16, i16, [4 x i8] } 58*9880d681SAndroid Build Coastguard Worker%"struct.ImageLoader::recursive_lock" = type { i32, i32 } 59*9880d681SAndroid Build Coastguard Worker 60*9880d681SAndroid Build Coastguard Worker@G1 = external hidden global %"struct.dyld::MappedRanges", align 8 61*9880d681SAndroid Build Coastguard Worker 62*9880d681SAndroid Build Coastguard Workerdeclare void @OSMemoryBarrier() optsize 63*9880d681SAndroid Build Coastguard Worker 64*9880d681SAndroid Build Coastguard Worker; Test the code below uses UNWIND_X86_64_MODE_STACK_IMMD compact unwind 65*9880d681SAndroid Build Coastguard Worker; encoding. 66*9880d681SAndroid Build Coastguard Worker 67*9880d681SAndroid Build Coastguard Worker; NOFP-CU: Entry at offset 0x20: 68*9880d681SAndroid Build Coastguard Worker; NOFP-CU-NEXT: start: 0x1d _test1 69*9880d681SAndroid Build Coastguard Worker; NOFP-CU-NEXT: length: 0x42 70*9880d681SAndroid Build Coastguard Worker; NOFP-CU-NEXT: compact encoding: 0x02040c0a 71*9880d681SAndroid Build Coastguard Worker 72*9880d681SAndroid Build Coastguard Worker; NOFP-FROM-ASM: Entry at offset 0x20: 73*9880d681SAndroid Build Coastguard Worker; NOFP-FROM-ASM-NEXT: start: 0x1d _test1 74*9880d681SAndroid Build Coastguard Worker; NOFP-FROM-ASM-NEXT: length: 0x42 75*9880d681SAndroid Build Coastguard Worker; NOFP-FROM-ASM-NEXT: compact encoding: 0x02040c0a 76*9880d681SAndroid Build Coastguard Worker 77*9880d681SAndroid Build Coastguard Workerdefine void @test1(%class.ImageLoader* %image) optsize ssp uwtable { 78*9880d681SAndroid Build Coastguard Workerentry: 79*9880d681SAndroid Build Coastguard Worker br label %for.cond1.preheader 80*9880d681SAndroid Build Coastguard Worker 81*9880d681SAndroid Build Coastguard Workerfor.cond1.preheader: ; preds = %for.inc10, %entry 82*9880d681SAndroid Build Coastguard Worker %p.019 = phi %"struct.dyld::MappedRanges"* [ @G1, %entry ], [ %1, %for.inc10 ] 83*9880d681SAndroid Build Coastguard Worker br label %for.body3 84*9880d681SAndroid Build Coastguard Worker 85*9880d681SAndroid Build Coastguard Workerfor.body3: ; preds = %for.inc, %for.cond1.preheader 86*9880d681SAndroid Build Coastguard Worker %indvars.iv = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next, %for.inc ] 87*9880d681SAndroid Build Coastguard Worker %image4 = getelementptr inbounds %"struct.dyld::MappedRanges", %"struct.dyld::MappedRanges"* %p.019, i64 0, i32 0, i64 %indvars.iv, i32 0 88*9880d681SAndroid Build Coastguard Worker %0 = load %class.ImageLoader*, %class.ImageLoader** %image4, align 8 89*9880d681SAndroid Build Coastguard Worker %cmp5 = icmp eq %class.ImageLoader* %0, %image 90*9880d681SAndroid Build Coastguard Worker br i1 %cmp5, label %if.then, label %for.inc 91*9880d681SAndroid Build Coastguard Worker 92*9880d681SAndroid Build Coastguard Workerif.then: ; preds = %for.body3 93*9880d681SAndroid Build Coastguard Worker tail call void @OSMemoryBarrier() optsize 94*9880d681SAndroid Build Coastguard Worker store %class.ImageLoader* null, %class.ImageLoader** %image4, align 8 95*9880d681SAndroid Build Coastguard Worker br label %for.inc 96*9880d681SAndroid Build Coastguard Worker 97*9880d681SAndroid Build Coastguard Workerfor.inc: ; preds = %if.then, %for.body3 98*9880d681SAndroid Build Coastguard Worker %indvars.iv.next = add i64 %indvars.iv, 1 99*9880d681SAndroid Build Coastguard Worker %lftr.wideiv = trunc i64 %indvars.iv.next to i32 100*9880d681SAndroid Build Coastguard Worker %exitcond = icmp eq i32 %lftr.wideiv, 400 101*9880d681SAndroid Build Coastguard Worker br i1 %exitcond, label %for.inc10, label %for.body3 102*9880d681SAndroid Build Coastguard Worker 103*9880d681SAndroid Build Coastguard Workerfor.inc10: ; preds = %for.inc 104*9880d681SAndroid Build Coastguard Worker %next = getelementptr inbounds %"struct.dyld::MappedRanges", %"struct.dyld::MappedRanges"* %p.019, i64 0, i32 1 105*9880d681SAndroid Build Coastguard Worker %1 = load %"struct.dyld::MappedRanges"*, %"struct.dyld::MappedRanges"** %next, align 8 106*9880d681SAndroid Build Coastguard Worker %cmp = icmp eq %"struct.dyld::MappedRanges"* %1, null 107*9880d681SAndroid Build Coastguard Worker br i1 %cmp, label %for.end11, label %for.cond1.preheader 108*9880d681SAndroid Build Coastguard Worker 109*9880d681SAndroid Build Coastguard Workerfor.end11: ; preds = %for.inc10 110*9880d681SAndroid Build Coastguard Worker ret void 111*9880d681SAndroid Build Coastguard Worker} 112