[llvm] r296395 - ISel: We need to notify FastIS of the IMPLICIT_DEF we created in createSwiftErrorEntriesInEntryBlock
Arnold Schwaighofer via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 27 14:12:06 PST 2017
Author: arnolds
Date: Mon Feb 27 16:12:06 2017
New Revision: 296395
URL: http://llvm.org/viewvc/llvm-project?rev=296395&view=rev
Log:
ISel: We need to notify FastIS of the IMPLICIT_DEF we created in createSwiftErrorEntriesInEntryBlock
Otherwise, it will insert instructions before it.
rdar://30536186
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/trunk/test/CodeGen/X86/swifterror.ll
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=296395&r1=296394&r2=296395&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Feb 27 16:12:06 2017
@@ -1306,6 +1306,7 @@ static void setupSwiftErrorVals(const Fu
}
static void createSwiftErrorEntriesInEntryBlock(FunctionLoweringInfo *FuncInfo,
+ FastISel *FastIS,
const TargetLowering *TLI,
const TargetInstrInfo *TII,
SelectionDAGBuilder *SDB) {
@@ -1332,6 +1333,11 @@ static void createSwiftErrorEntriesInEnt
BuildMI(*FuncInfo->MBB, FuncInfo->MBB->getFirstNonPHI(),
SDB->getCurDebugLoc(), TII->get(TargetOpcode::IMPLICIT_DEF),
VReg);
+
+ // Keep FastIS informed about the value we just inserted.
+ if (FastIS)
+ FastIS->setLastLocalValue(&*std::prev(FuncInfo->InsertPt));
+
FuncInfo->setCurrentSwiftErrorVReg(FuncInfo->MBB, SwiftErrorVal, VReg);
}
}
@@ -1501,7 +1507,7 @@ void SelectionDAGISel::SelectAllBasicBlo
else
FastIS->setLastLocalValue(nullptr);
}
- createSwiftErrorEntriesInEntryBlock(FuncInfo, TLI, TII, SDB);
+ createSwiftErrorEntriesInEntryBlock(FuncInfo, FastIS, TLI, TII, SDB);
// Iterate over all basic blocks in the function.
for (const BasicBlock *LLVMBB : RPOT) {
Modified: llvm/trunk/test/CodeGen/X86/swifterror.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/swifterror.ll?rev=296395&r1=296394&r2=296395&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/swifterror.ll (original)
+++ llvm/trunk/test/CodeGen/X86/swifterror.ll Mon Feb 27 16:12:06 2017
@@ -685,3 +685,30 @@ entry:
tail call void @acallee(i8* null)
ret void
}
+
+; Make sure we don't crash on this function during -O0.
+; We used to crash because we would insert an IMPLICIT_DEF for the swifterror at
+; beginning of the machine basic block but did not inform FastISel of the
+; inserted instruction. When computing the InsertPoint in the entry block
+; FastISel would choose an insertion point before the IMPLICIT_DEF causing a
+; crash later on.
+declare hidden swiftcc i8* @testFunA()
+
+%TSb = type <{ i1 }>
+
+define swiftcc void @dontCrash() {
+entry:
+ %swifterror = alloca swifterror %swift_error*, align 8
+ store %swift_error* null, %swift_error** %swifterror, align 8
+ %a = call i8* @testFunA()
+ %b = bitcast i8* %a to %TSb*
+ %._value = getelementptr inbounds %TSb, %TSb* %b, i32 0, i32 0
+ %c = load i1, i1* %._value, align 1
+ br i1 %c, label %trueBB, label %falseBB
+
+trueBB:
+ ret void
+
+falseBB:
+ ret void
+}
More information about the llvm-commits
mailing list