[llvm] r264127 - [StatepointLowering] Schedule gc relocates before uniqueing them
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 22 19:24:07 PDT 2016
Author: sanjoy
Date: Tue Mar 22 21:24:07 2016
New Revision: 264127
URL: http://llvm.org/viewvc/llvm-project?rev=264127&view=rev
Log:
[StatepointLowering] Schedule gc relocates before uniqueing them
Otherwise we can see an "unexpected" gc.relocate that we uniqued away.
Added:
llvm/trunk/test/CodeGen/X86/statepoint-duplicate-gcrelocate.ll
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h?rev=264127&r1=264126&r2=264127&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h Tue Mar 22 21:24:07 2016
@@ -732,11 +732,11 @@ public:
struct StatepointLoweringInfo {
/// Bases[i] is the base pointer for Ptrs[i]. Together they denote the set
/// of gc pointers this STATEPOINT has to relocate.
- ArrayRef<const Value *> Bases;
- ArrayRef<const Value *> Ptrs;
+ SmallVector<const Value *, 16> Bases;
+ SmallVector<const Value *, 16> Ptrs;
/// The set of gc.relocate calls associated with this gc.statepoint.
- ArrayRef<const GCRelocateInst *> GCRelocates;
+ SmallVector<const GCRelocateInst *, 16> GCRelocates;
/// The full list of gc arguments to the gc.statepoint being lowered.
ArrayRef<const Use> GCArgs;
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp?rev=264127&r1=264126&r2=264127&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp Tue Mar 22 21:24:07 2016
@@ -334,12 +334,6 @@ static void getIncomingStatepointGCValue
Ptrs.push_back(Relocate->getDerivedPtr());
}
- // Remove any redundant llvm::Values which map to the same SDValue as another
- // input. Also has the effect of removing duplicates in the original
- // llvm::Value input list as well. This is a useful optimization for
- // reducing the size of the StackMap section. It has no other impact.
- removeDuplicatesGCPtrs(Bases, Ptrs, Relocs, Builder);
-
assert(Bases.size() == Ptrs.size() && Ptrs.size() == Relocs.size());
}
@@ -566,11 +560,21 @@ SDValue SelectionDAGBuilder::LowerAsSTAT
StatepointLowering.startNewStatepoint(*this);
#ifndef NDEBUG
+ // We schedule gc relocates before removeDuplicatesGCPtrs since we _will_
+ // encounter the duplicate gc relocates we elide in removeDuplicatesGCPtrs.
for (auto *Reloc : SI.GCRelocates)
if (Reloc->getParent() == SI.StatepointInstr->getParent())
StatepointLowering.scheduleRelocCall(*Reloc);
#endif
+ // Remove any redundant llvm::Values which map to the same SDValue as another
+ // input. Also has the effect of removing duplicates in the original
+ // llvm::Value input list as well. This is a useful optimization for
+ // reducing the size of the StackMap section. It has no other impact.
+ removeDuplicatesGCPtrs(SI.Bases, SI.Ptrs, SI.GCRelocates, *this);
+ assert(SI.Bases.size() == SI.Ptrs.size() &&
+ SI.Ptrs.size() == SI.GCRelocates.size());
+
// Lower statepoint vmstate and gcstate arguments
SmallVector<SDValue, 10> LoweredMetaArgs;
lowerStatepointMetaArgs(LoweredMetaArgs, SI, *this);
Added: llvm/trunk/test/CodeGen/X86/statepoint-duplicate-gcrelocate.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/statepoint-duplicate-gcrelocate.ll?rev=264127&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/statepoint-duplicate-gcrelocate.ll (added)
+++ llvm/trunk/test/CodeGen/X86/statepoint-duplicate-gcrelocate.ll Tue Mar 22 21:24:07 2016
@@ -0,0 +1,20 @@
+; RUN: llc < %s | FileCheck %s
+
+; Checks for a crash we had when two gc.relocate calls would
+; relocating identical values
+
+target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-linux-gnu"
+
+declare void @f()
+declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
+declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token, i32, i32) #3
+
+define void @test(i32 addrspace(1)* %ptr) gc "statepoint-example" {
+; CHECK-LABEL: test
+ %tok = tail call token (i64, i32, void ()*, i32, i32, ...)
+ @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @f, i32 0, i32 0, i32 0, i32 2, i32 addrspace(1)* %ptr, i32 undef, i32 addrspace(1)* %ptr, i32 addrspace(1)* %ptr)
+ %a = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %tok, i32 9, i32 9)
+ %b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %tok, i32 10, i32 10)
+ ret void
+}
More information about the llvm-commits
mailing list