summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiogo Sampaio <diogo.sampaio@arm.com>2020-02-06 08:54:30 +0000
committerHans Wennborg <hans@chromium.org>2020-02-10 13:27:45 +0100
commita124bebdd5ff5cf49480956258c322ed9204943c (patch)
treed2231c4c8f5fa3987c72526a8b372a7b0b459282
parent4ea0b397582a623cdaaca97ed304002531f9575d (diff)
downloadbcm5719-llvm-a124bebdd5ff5cf49480956258c322ed9204943c.tar.gz
bcm5719-llvm-a124bebdd5ff5cf49480956258c322ed9204943c.zip
[ARM] Fix non-determenistic behaviour
Summary: ARM Type Promotion pass does not clear the container that defines if one variable was visited or not, missing optimization opportunities by luck when two llvm:Values from different functions are allocated at the same memory address. Also fixes a comment and uses existing method to pop and obtain last element of the worklist. Reviewers: samparker Reviewed By: samparker Subscribers: kristof.beyls, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D73970 (cherry picked from commit 8ba2b6281075c65c1a47abed57810e1201942533)
-rw-r--r--llvm/lib/CodeGen/TypePromotion.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TypePromotion.cpp b/llvm/lib/CodeGen/TypePromotion.cpp
index 4522484222f..e8b39c03769 100644
--- a/llvm/lib/CodeGen/TypePromotion.cpp
+++ b/llvm/lib/CodeGen/TypePromotion.cpp
@@ -847,8 +847,7 @@ bool TypePromotion::TryToPromote(Value *V, unsigned PromotedWidth) {
// Iterate through, and add to, a tree of operands and users in the use-def.
while (!WorkList.empty()) {
- Value *V = WorkList.back();
- WorkList.pop_back();
+ Value *V = WorkList.pop_back_val();
if (CurrentVisited.count(V))
continue;
@@ -917,7 +916,7 @@ bool TypePromotion::TryToPromote(Value *V, unsigned PromotedWidth) {
++ToPromote;
}
- // DAG optimisations should be able to handle these cases better, especially
+ // DAG optimizations should be able to handle these cases better, especially
// for function arguments.
if (ToPromote < 2 || (Blocks.size() == 1 && (NonFreeArgs > SafeWrap.size())))
return false;
@@ -941,6 +940,9 @@ bool TypePromotion::runOnFunction(Function &F) {
if (!TPC)
return false;
+ AllVisited.clear();
+ SafeToPromote.clear();
+ SafeWrap.clear();
bool MadeChange = false;
const DataLayout &DL = F.getParent()->getDataLayout();
const TargetMachine &TM = TPC->getTM<TargetMachine>();
@@ -998,6 +1000,10 @@ bool TypePromotion::runOnFunction(Function &F) {
if (MadeChange)
LLVM_DEBUG(dbgs() << "After TypePromotion: " << F << "\n");
+ AllVisited.clear();
+ SafeToPromote.clear();
+ SafeWrap.clear();
+
return MadeChange;
}
OpenPOWER on IntegriCloud