From f708c59106e0ac4fafbbf0f23d0de3fb15fe9ea4 Mon Sep 17 00:00:00 2001 From: Serguei Katkov Date: Fri, 5 Apr 2019 05:41:08 +0000 Subject: [PATCH] [FastISel] Fix crash for gc.relocate lowring Lowering safepoint checks that all gc.relocaes observed in safepoint must be lowered. However Fast-Isel is able to skip dead gc.relocate. To resolve this issue we just ignore dead gc.relocate in the check. Reviewers: reames Reviewed By: reames Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D60184 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357742 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/StatepointLowering.h | 7 ++++++- test/CodeGen/X86/fast-isel-gc-intrinsics.ll | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/SelectionDAG/StatepointLowering.h b/lib/CodeGen/SelectionDAG/StatepointLowering.h index a4fdce515b9..70507932681 100644 --- a/lib/CodeGen/SelectionDAG/StatepointLowering.h +++ b/lib/CodeGen/SelectionDAG/StatepointLowering.h @@ -66,13 +66,18 @@ public: /// before the next statepoint. If we don't see it, we'll report /// an assertion. void scheduleRelocCall(const CallInst &RelocCall) { - PendingGCRelocateCalls.push_back(&RelocCall); + // We are not interested in lowering dead instructions. + if (!RelocCall.use_empty()) + PendingGCRelocateCalls.push_back(&RelocCall); } /// Remove this gc_relocate from the list we're expecting to see /// before the next statepoint. If we weren't expecting to see /// it, we'll report an assertion. void relocCallVisited(const CallInst &RelocCall) { + // We are not interested in lowering dead instructions. + if (RelocCall.use_empty()) + return; auto I = llvm::find(PendingGCRelocateCalls, &RelocCall); assert(I != PendingGCRelocateCalls.end() && "Visited unexpected gcrelocate call"); diff --git a/test/CodeGen/X86/fast-isel-gc-intrinsics.ll b/test/CodeGen/X86/fast-isel-gc-intrinsics.ll index ac09d7555a4..9943bed1e65 100644 --- a/test/CodeGen/X86/fast-isel-gc-intrinsics.ll +++ b/test/CodeGen/X86/fast-isel-gc-intrinsics.ll @@ -29,6 +29,8 @@ 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, i8 addrspace(1)* %v) %call1 = call zeroext i1 @llvm.experimental.gc.result.i1(token %safepoint_token) %vnew = call i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %safepoint_token, i32 7, i32 7) + br label %exit +exit: ret i1 %call1 } -- 2.40.0