[CodeGenPrepare] Use MapVector to stabilize iteration order
DenseMap iteration order is not guaranteed to be deterministic.
Without the change,
llvm/test/Transforms/CodeGenPrepare/X86/statepoint-relocate.ll would
fail when `combineHashValue` changes (#95970).
Fixes: dba7329ebb
This commit is contained in:
@@ -1194,12 +1194,12 @@ void CodeGenPrepare::eliminateMostlyEmptyBlock(BasicBlock *BB) {
|
||||
// derived pointer relocation instructions given a vector of all relocate calls
|
||||
static void computeBaseDerivedRelocateMap(
|
||||
const SmallVectorImpl<GCRelocateInst *> &AllRelocateCalls,
|
||||
DenseMap<GCRelocateInst *, SmallVector<GCRelocateInst *, 2>>
|
||||
MapVector<GCRelocateInst *, SmallVector<GCRelocateInst *, 0>>
|
||||
&RelocateInstMap) {
|
||||
// Collect information in two maps: one primarily for locating the base object
|
||||
// while filling the second map; the second map is the final structure holding
|
||||
// a mapping between Base and corresponding Derived relocate calls
|
||||
DenseMap<std::pair<unsigned, unsigned>, GCRelocateInst *> RelocateIdxMap;
|
||||
MapVector<std::pair<unsigned, unsigned>, GCRelocateInst *> RelocateIdxMap;
|
||||
for (auto *ThisRelocate : AllRelocateCalls) {
|
||||
auto K = std::make_pair(ThisRelocate->getBasePtrIndex(),
|
||||
ThisRelocate->getDerivedPtrIndex());
|
||||
@@ -1375,7 +1375,7 @@ bool CodeGenPrepare::simplifyOffsetableRelocate(GCStatepointInst &I) {
|
||||
|
||||
// RelocateInstMap is a mapping from the base relocate instruction to the
|
||||
// corresponding derived relocate instructions
|
||||
DenseMap<GCRelocateInst *, SmallVector<GCRelocateInst *, 2>> RelocateInstMap;
|
||||
MapVector<GCRelocateInst *, SmallVector<GCRelocateInst *, 0>> RelocateInstMap;
|
||||
computeBaseDerivedRelocateMap(AllRelocateCalls, RelocateInstMap);
|
||||
if (RelocateInstMap.empty())
|
||||
return false;
|
||||
|
||||
@@ -18,10 +18,11 @@ entry:
|
||||
}
|
||||
|
||||
define i32 @test_sor_two_derived(ptr addrspace(1) %base) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test_sor_two_derived(
|
||||
; CHECK: getelementptr i32, ptr addrspace(1) %base, i32 15
|
||||
; CHECK: getelementptr i32, ptr addrspace(1) %base, i32 12
|
||||
; CHECK: getelementptr i32, ptr addrspace(1) %base-new, i32 12
|
||||
; CHECK: getelementptr i32, ptr addrspace(1) %base-new, i32 15
|
||||
; CHECK: getelementptr i32, ptr addrspace(1) %base-new, i32 12
|
||||
entry:
|
||||
%ptr = getelementptr i32, ptr addrspace(1) %base, i32 15
|
||||
%ptr2 = getelementptr i32, ptr addrspace(1) %base, i32 12
|
||||
@@ -34,6 +35,7 @@ entry:
|
||||
}
|
||||
|
||||
define i32 @test_sor_ooo(ptr addrspace(1) %base) gc "statepoint-example" {
|
||||
; CHECK-LABEL: @test_sor_ooo(
|
||||
; CHECK: getelementptr i32, ptr addrspace(1) %base, i32 15
|
||||
; CHECK: getelementptr i32, ptr addrspace(1) %base-new, i32 15
|
||||
entry:
|
||||
|
||||
Reference in New Issue
Block a user