[llvm] 7497b86 - [GlobalISel][IRTranslator] Support PHI instructions in landingpad blocks
Konstantin Schwarz via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 20 01:50:44 PDT 2020
Author: Konstantin Schwarz
Date: 2020-08-20T10:49:31+02:00
New Revision: 7497b861f49629e84be1215b8d2da18898b1097c
URL: https://github.com/llvm/llvm-project/commit/7497b861f49629e84be1215b8d2da18898b1097c
DIFF: https://github.com/llvm/llvm-project/commit/7497b861f49629e84be1215b8d2da18898b1097c.diff
LOG: [GlobalISel][IRTranslator] Support PHI instructions in landingpad blocks
The check for the landingpad instructions was overly restrictive. In optimimized builds PHI nodes can appear
before the landingpad instructions, resulting in a fallback to SelectionDAG.
This change relaxes the check to allow PHI nodes.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D86141
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-exceptions.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index adf90a8d740a..46041f0a8a82 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -2030,7 +2030,7 @@ bool IRTranslator::translateInvoke(const User &U,
return false;
// FIXME: support Windows exception handling.
- if (!isa<LandingPadInst>(EHPadBB->front()))
+ if (!isa<LandingPadInst>(EHPadBB->getFirstNonPHI()))
return false;
// Emit the actual call, bracketed by EH_LABELs so that the MF knows about
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-exceptions.ll b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-exceptions.ll
index 528a2adbe67b..c3c97a22b2c2 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-exceptions.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-exceptions.ll
@@ -87,3 +87,42 @@ broken:
continue:
ret void
}
+
+; CHECK-LABEL: name: test_lpad_phi
+; CHECK: body:
+; CHECK-NEXT: bb.1 (%ir-block.0):
+; CHECK: successors: %[[GOOD:bb.[0-9]+]]{{.*}}%[[BAD:bb.[0-9]+]]
+; CHECK: [[ELEVEN:%[0-9]+]]:_(s32) = G_CONSTANT i32 11
+; CHECK: EH_LABEL
+; CHECK: BL @may_throw, csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp
+; CHECK: EH_LABEL
+; CHECK: G_BR %[[GOOD]]
+
+; CHECK: [[BAD]].{{[a-z]+}} (landing-pad):
+; CHECK: [[PHI_ELEVEN:%[0-9]+]]:_(s32) = G_PHI [[ELEVEN]](s32), %bb.1
+; CHECK: EH_LABEL
+; CHECK: G_STORE [[PHI_ELEVEN]](s32), {{%[0-9]+}}(p0) :: (store 4 into @global_var)
+
+; CHECK: [[GOOD]].{{[a-z]+}}:
+; CHECK: [[SEL:%[0-9]+]]:_(s32) = G_PHI
+; CHECK: $w0 = COPY [[SEL]]
+
+ at global_var = external global i32
+
+declare void @may_throw()
+define i32 @test_lpad_phi() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+ store i32 42, i32* @global_var
+ invoke void @may_throw()
+ to label %continue unwind label %lpad
+
+lpad: ; preds = %entry
+ %p = phi i32 [ 11, %0 ] ; Trivial, but -O0 keeps it
+ %1 = landingpad { i8*, i32 }
+ catch i8* null
+ store i32 %p, i32* @global_var
+ br label %continue
+
+continue: ; preds = %entry, %lpad
+ %r.0 = phi i32 [ 13, %0 ], [ 55, %lpad ]
+ ret i32 %r.0
+}
More information about the llvm-commits
mailing list