]> granicus.if.org Git - llvm/commitdiff
[FastISel] Fix the crash in gc.result lowering
authorSerguei Katkov <serguei.katkov@azul.com>
Thu, 4 Apr 2019 04:19:56 +0000 (04:19 +0000)
committerSerguei Katkov <serguei.katkov@azul.com>
Thu, 4 Apr 2019 04:19:56 +0000 (04:19 +0000)
The Fast ISel has a fallback to SelectionDAGISel in case it cannot handle the instruction.
This works as follows:
Using reverse order, try to select instruction using Fast ISel, if it cannot handle instruction it fallbacks to SelectionDAGISel
for these instructions if it is a call and continue fast instruction selections.

However if unhandled instruction is not a call or statepoint related instruction it fallbacks to SelectionDAGISel for all remaining
instructions in basic block.

However gc.result instruction is missed and as a result it is possible that gc.result is processed earlier than statepoint
causing breakage invariant the gc.results should be handled after statepoint.

Test is updated because in the current form fast-isel cannot handle ret instruction (due to i1 ret type without explicit ext)
and as a result test does not check fast-isel at all.

Reviewers: reames
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D60182

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357672 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
test/CodeGen/X86/fast-isel-gc-intrinsics.ll

index 2b3a69779d3407ca51044d4e28d3bd16d9157c05..61c9e5a5252558ba462acff564c1a1fb0e7bd061 100644 (file)
@@ -1721,7 +1721,8 @@ void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) {
         // to keep track of gc-relocates for a particular gc-statepoint. This is
         // done by SelectionDAGBuilder::LowerAsSTATEPOINT, called before
         // visitGCRelocate.
-        if (isa<CallInst>(Inst) && !isStatepoint(Inst) && !isGCRelocate(Inst)) {
+        if (isa<CallInst>(Inst) && !isStatepoint(Inst) && !isGCRelocate(Inst) &&
+            !isGCResult(Inst)) {
           OptimizationRemarkMissed R("sdagisel", "FastISelFailure",
                                      Inst->getDebugLoc(), LLVMBB);
 
index bf08ad01d7d8cd6683a402377a9fce5fc02575fd..ac09d7555a45bf632a757680185bccb358e502a2 100644 (file)
@@ -17,6 +17,8 @@ define i1 @test_gcresult() gc "statepoint-example" {
 entry:
   %safepoint_token = tail call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 0)
   %call1 = call zeroext i1 @llvm.experimental.gc.result.i1(token %safepoint_token)
+  br label %exit
+exit:
   ret i1 %call1
 }