[llvm] r357672 - [FastISel] Fix the crash in gc.result lowering

Serguei Katkov via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 3 21:19:57 PDT 2019


Author: skatkov
Date: Wed Apr  3 21:19:56 2019
New Revision: 357672

URL: http://llvm.org/viewvc/llvm-project?rev=357672&view=rev
Log:
[FastISel] Fix the crash in gc.result lowering

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

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
    llvm/trunk/test/CodeGen/X86/fast-isel-gc-intrinsics.ll

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=357672&r1=357671&r2=357672&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Wed Apr  3 21:19:56 2019
@@ -1721,7 +1721,8 @@ void SelectionDAGISel::SelectAllBasicBlo
         // 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);
 

Modified: llvm/trunk/test/CodeGen/X86/fast-isel-gc-intrinsics.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-gc-intrinsics.ll?rev=357672&r1=357671&r2=357672&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fast-isel-gc-intrinsics.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fast-isel-gc-intrinsics.ll Wed Apr  3 21:19:56 2019
@@ -17,6 +17,8 @@ define i1 @test_gcresult() gc "statepoin
 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
 }
 




More information about the llvm-commits mailing list