diff options
| author | Joseph Tremoulet <jotrem@microsoft.com> | 2015-10-23 15:06:05 +0000 |
|---|---|---|
| committer | Joseph Tremoulet <jotrem@microsoft.com> | 2015-10-23 15:06:05 +0000 |
| commit | 3d0fbf1d74fd1a8f55d1313e9bfc216e7ad9f02b (patch) | |
| tree | c3998aa9dc4e4c81b543fbf5b7e27f2d782b58a6 /llvm/test/CodeGen/X86/late-address-taken.ll | |
| parent | 05a896a8d1745c260ac21577c3e12ddee4ea1923 (diff) | |
| download | bcm5719-llvm-3d0fbf1d74fd1a8f55d1313e9bfc216e7ad9f02b.tar.gz bcm5719-llvm-3d0fbf1d74fd1a8f55d1313e9bfc216e7ad9f02b.zip | |
[CodeGen] Mark setjmp/catchret MBBs address-taken
Summary:
This ensures that BranchFolding (and similar) won't remove these blocks.
Also allow AsmPrinter::EmitBasicBlockStart to process MBBs which are
address-taken but do not have BBs that are address-taken, since otherwise
its call to getAddrLabelSymbolTableToEmit would fail an assertion on such
blocks. I audited the other callers of getAddrLabelSymbolTableToEmit
(and getAddrLabelSymbol); they all have BBs known to be address-taken
except for the call through getAddrLabelSymbol from
WinException::create32bitRef; that call is actually now unreachable, so
I've removed it and updated the signature of create32bitRef.
This fixes PR25168.
Reviewers: majnemer, andrew.w.kaylor, rnk
Subscribers: pgavlin, llvm-commits
Differential Revision: http://reviews.llvm.org/D13774
llvm-svn: 251113
Diffstat (limited to 'llvm/test/CodeGen/X86/late-address-taken.ll')
| -rw-r--r-- | llvm/test/CodeGen/X86/late-address-taken.ll | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/late-address-taken.ll b/llvm/test/CodeGen/X86/late-address-taken.ll new file mode 100644 index 00000000000..7d4dde80bbd --- /dev/null +++ b/llvm/test/CodeGen/X86/late-address-taken.ll @@ -0,0 +1,68 @@ +; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s | FileCheck %s + +; Repro cases from PR25168 + +; test @catchret - catchret target is not address-taken until PEI +; splits it into lea/mov followed by ret. Make sure the MBB is +; handled, both by tempting BranchFolding to merge it with %early_out +; and delete it, and by checking that we emit a proper reference +; to it in the LEA + +declare void @ProcessCLRException() +declare void @f() + +define void @catchret(i1 %b) personality void ()* @ProcessCLRException { +entry: + br i1 %b, label %body, label %early_out +early_out: + ret void +body: + invoke void @f() + to label %exit unwind label %catch.pad +catch.pad: + %catch = catchpad [i32 33554467] + to label %catch.body unwind label %catch.end +catch.body: + catchret %catch to label %exit +catch.end: + catchendpad unwind to caller +exit: + ret void +} +; CHECK-LABEL: catchret: # @catchret +; CHECK: [[Exit:^[^ :]+]]: # Block address taken +; CHECK-NEXT: # %exit +; CHECK: # %catch.pad +; CHECK: .seh_endprolog +; CHECK: leaq [[Exit]](%rip), %rax +; CHECK: retq # CATCHRET + + +; test @setjmp - similar to @catchret, but the MBB in question +; is the one generated when the setjmp's block is split + +@buf = internal global [5 x i8*] zeroinitializer +declare i8* @llvm.frameaddress(i32) nounwind readnone +declare i8* @llvm.stacksave() nounwind +declare i32 @llvm.eh.sjlj.setjmp(i8*) nounwind +declare void @llvm.eh.sjlj.longjmp(i8*) nounwind + +define void @setjmp(i1 %b) nounwind { +entry: + br i1 %b, label %early_out, label %sj +early_out: + ret void +sj: + %fp = call i8* @llvm.frameaddress(i32 0) + store i8* %fp, i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @buf, i64 0, i64 0), align 16 + %sp = call i8* @llvm.stacksave() + store i8* %sp, i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @buf, i64 0, i64 2), align 16 + call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([5 x i8*]* @buf to i8*)) + ret void +} +; CHECK-LABEL: setjmp: # @setjmp +; CHECK: # %sj +; CHECK: leaq [[Label:\..+]](%rip), %[[Reg:.+]]{{$}} +; CHECK-NEXT: movq %[[Reg]], buf +; CHECK: {{^}}[[Label]]: # Block address taken +; CHECK-NEXT: # %sj |

