diff options
author | Hiroshi Inoue <inouehrs@jp.ibm.com> | 2017-08-02 18:16:32 +0000 |
---|---|---|
committer | Hiroshi Inoue <inouehrs@jp.ibm.com> | 2017-08-02 18:16:32 +0000 |
commit | 0bd906ec8f7839ac9a802b82b48444d647bba88c (patch) | |
tree | b8bfb49cae922646a0f6759db29eb79a85706c78 /llvm | |
parent | f67036b62c0c595d4e06c87a80d58aceb4b83883 (diff) | |
download | bcm5719-llvm-0bd906ec8f7839ac9a802b82b48444d647bba88c.tar.gz bcm5719-llvm-0bd906ec8f7839ac9a802b82b48444d647bba88c.zip |
[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
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/CodeGen/StackColoring.cpp | 8 |
2 files changed, 10 insertions, 11 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 9e80bbef3c8..9ab98ce6175 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -3319,13 +3319,6 @@ void llvm::getUnderlyingObjectsForCodeGen(const Value *V, GetUnderlyingObjects(const_cast<Value *>(V), Objs, DL); for (Value *V : Objs) { - // If GetUnderlyingObjects fails to find an identifiable object, - // getUnderlyingObjectsForCodeGen also fails for safety. - if (!isIdentifiedObject(V)) { - Objects.clear(); - return; - } - if (!Visited.insert(V).second) continue; if (Operator::getOpcode(V) == Instruction::IntToPtr) { @@ -3336,6 +3329,12 @@ void llvm::getUnderlyingObjectsForCodeGen(const Value *V, continue; } } + // If GetUnderlyingObjects fails to find an identifiable object, + // getUnderlyingObjectsForCodeGen also fails for safety. + if (!isIdentifiedObject(V)) { + Objects.clear(); + return; + } Objects.push_back(const_cast<Value *>(V)); } } while (!Working.empty()); diff --git a/llvm/lib/CodeGen/StackColoring.cpp b/llvm/lib/CodeGen/StackColoring.cpp index d35bdea4472..e5fc5402cb4 100644 --- a/llvm/lib/CodeGen/StackColoring.cpp +++ b/llvm/lib/CodeGen/StackColoring.cpp @@ -1001,7 +1001,7 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) { } // We adjust AliasAnalysis information for merged stack slots. - MachineSDNode::mmo_iterator MemOps = + MachineSDNode::mmo_iterator NewMemOps = MF->allocateMemRefsArray(I.getNumMemOperands()); unsigned MemOpIdx = 0; bool ReplaceMemOps = false; @@ -1030,17 +1030,17 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) { } } if (MayHaveConflictingAAMD) { - MemOps[MemOpIdx++] = MF->getMachineMemOperand(MMO, AAMDNodes()); + NewMemOps[MemOpIdx++] = MF->getMachineMemOperand(MMO, AAMDNodes()); ReplaceMemOps = true; } else - MemOps[MemOpIdx++] = MMO; + NewMemOps[MemOpIdx++] = MMO; } // If any memory operand is updated, set memory references of // this instruction. if (ReplaceMemOps) - I.setMemRefs(std::make_pair(MemOps, I.getNumMemOperands())); + I.setMemRefs(std::make_pair(NewMemOps, I.getNumMemOperands())); } // Update the location of C++ catch objects for the MSVC personality routine. |