Skip to content

Commit 0bd906e

Browse files
committed
[StackColoring] Update AliasAnalysis information in stack coloring pass (part 2)
This patch is update after the first patch (https://reviews.llvm.org/rL309651) based on the post-commit comments. Stack coloring pass need to maintain AliasAnalysis information when merging stack slots of different types. Actually, there is a FIXME comment in StackColoring.cpp // FIXME: In order to enable the use of TBAA when using AA in CodeGen, // we'll also need to update the TBAA nodes in MMOs with values // derived from the merged allocas. But, TBAA has been already enabled in CodeGen without fixing this pass. The incorrect TBAA metadata results in recent failures in bootstrap test on ppc64le (PR33928) by allowing unsafe instruction scheduling. Although we observed the problem on ppc64le, this is a platform neutral issue. This patch makes the stack coloring pass maintains AliasAnalysis information when merging multiple stack slots. This patch fixes PR33928. llvm-svn: 309849
1 parent f67036b commit 0bd906e

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3319,13 +3319,6 @@ void llvm::getUnderlyingObjectsForCodeGen(const Value *V,
33193319
GetUnderlyingObjects(const_cast<Value *>(V), Objs, DL);
33203320

33213321
for (Value *V : Objs) {
3322-
// If GetUnderlyingObjects fails to find an identifiable object,
3323-
// getUnderlyingObjectsForCodeGen also fails for safety.
3324-
if (!isIdentifiedObject(V)) {
3325-
Objects.clear();
3326-
return;
3327-
}
3328-
33293322
if (!Visited.insert(V).second)
33303323
continue;
33313324
if (Operator::getOpcode(V) == Instruction::IntToPtr) {
@@ -3336,6 +3329,12 @@ void llvm::getUnderlyingObjectsForCodeGen(const Value *V,
33363329
continue;
33373330
}
33383331
}
3332+
// If GetUnderlyingObjects fails to find an identifiable object,
3333+
// getUnderlyingObjectsForCodeGen also fails for safety.
3334+
if (!isIdentifiedObject(V)) {
3335+
Objects.clear();
3336+
return;
3337+
}
33393338
Objects.push_back(const_cast<Value *>(V));
33403339
}
33413340
} while (!Working.empty());

llvm/lib/CodeGen/StackColoring.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
10011001
}
10021002

10031003
// We adjust AliasAnalysis information for merged stack slots.
1004-
MachineSDNode::mmo_iterator MemOps =
1004+
MachineSDNode::mmo_iterator NewMemOps =
10051005
MF->allocateMemRefsArray(I.getNumMemOperands());
10061006
unsigned MemOpIdx = 0;
10071007
bool ReplaceMemOps = false;
@@ -1030,17 +1030,17 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
10301030
}
10311031
}
10321032
if (MayHaveConflictingAAMD) {
1033-
MemOps[MemOpIdx++] = MF->getMachineMemOperand(MMO, AAMDNodes());
1033+
NewMemOps[MemOpIdx++] = MF->getMachineMemOperand(MMO, AAMDNodes());
10341034
ReplaceMemOps = true;
10351035
}
10361036
else
1037-
MemOps[MemOpIdx++] = MMO;
1037+
NewMemOps[MemOpIdx++] = MMO;
10381038
}
10391039

10401040
// If any memory operand is updated, set memory references of
10411041
// this instruction.
10421042
if (ReplaceMemOps)
1043-
I.setMemRefs(std::make_pair(MemOps, I.getNumMemOperands()));
1043+
I.setMemRefs(std::make_pair(NewMemOps, I.getNumMemOperands()));
10441044
}
10451045

10461046
// Update the location of C++ catch objects for the MSVC personality routine.

0 commit comments

Comments
 (0)