[llvm] r353242 - [HotColdSplit] Do not split out `resume` instructions
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 5 15:39:02 PST 2019
Author: vedantk
Date: Tue Feb 5 15:39:02 2019
New Revision: 353242
URL: http://llvm.org/viewvc/llvm-project?rev=353242&view=rev
Log:
[HotColdSplit] Do not split out `resume` instructions
Resumes that are not reachable from a cleanup landing pad are considered
to be unreachable. It’s not safe to split them out.
rdar://47808235
Modified:
llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp
llvm/trunk/test/Transforms/HotColdSplit/resume.ll
llvm/trunk/test/Transforms/HotColdSplit/unwind.ll
Modified: llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp?rev=353242&r1=353241&r2=353242&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp Tue Feb 5 15:39:02 2019
@@ -135,8 +135,12 @@ static bool mayExtractBlock(const BasicB
// EH pads are unsafe to outline because doing so breaks EH type tables. It
// follows that invoke instructions cannot be extracted, because CodeExtractor
// requires unwind destinations to be within the extraction region.
- return !BB.hasAddressTaken() && !BB.isEHPad() &&
- !isa<InvokeInst>(BB.getTerminator());
+ //
+ // Resumes that are not reachable from a cleanup landing pad are considered to
+ // be unreachable. Itâs not safe to split them out either.
+ auto Term = BB.getTerminator();
+ return !BB.hasAddressTaken() && !BB.isEHPad() && !isa<InvokeInst>(Term) &&
+ !isa<ResumeInst>(Term);
}
/// Mark \p F cold. Based on this assumption, also optimize it for minimum size.
Modified: llvm/trunk/test/Transforms/HotColdSplit/resume.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/HotColdSplit/resume.ll?rev=353242&r1=353241&r2=353242&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/HotColdSplit/resume.ll (original)
+++ llvm/trunk/test/Transforms/HotColdSplit/resume.ll Tue Feb 5 15:39:02 2019
@@ -6,11 +6,17 @@ target triple = "x86_64-apple-macosx10.1
; Consider `resume` to be cold.
; CHECK-LABEL: define {{.*}}@foo.cold.1(
-; CHECK: resume i32 undef
+; CHECK: call {{.*}}@sink(
-define i32 @foo(i32 %cond) personality i8 0 {
+declare void @sink() cold
+
+define i32 @foo() personality i8 0 {
entry:
- br i1 undef, label %resume-eh, label %normal
+ br i1 undef, label %pre-resume-eh, label %normal
+
+pre-resume-eh:
+ call void @sink()
+ br label %resume-eh
resume-eh:
resume i32 undef
Modified: llvm/trunk/test/Transforms/HotColdSplit/unwind.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/HotColdSplit/unwind.ll?rev=353242&r1=353241&r2=353242&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/HotColdSplit/unwind.ll (original)
+++ llvm/trunk/test/Transforms/HotColdSplit/unwind.ll Tue Feb 5 15:39:02 2019
@@ -3,12 +3,15 @@
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.14.0"
-; Do not mark outlined functions which resume exception unwinding as noreturn.
+; Do not split out `resume` instructions.
; CHECK-LABEL: define {{.*}}@foo.cold.1(
-; CHECK: resume
+; CHECK: call {{.*}}@sink(
+; CHECK-NOT: resume i32 undef
+
; CHECK-NOT: noreturn
-define i32 @foo(i32 %cond) personality i8 0 {
+
+define i32 @foo() personality i8 0 {
entry:
invoke void @llvm.donothing() to label %normal unwind label %exception
@@ -19,6 +22,9 @@ exception:
continue_exception:
call void @sideeffect(i32 0)
call void @sink()
+ br label %resume-eh
+
+resume-eh:
resume i32 undef
normal:
More information about the llvm-commits
mailing list