summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorNeil Henning <neil.henning@amd.com>2018-10-10 09:27:45 +0000
committerNeil Henning <neil.henning@amd.com>2018-10-10 09:27:45 +0000
commit3d4579829e85c108e729ade64d778e614b702e16 (patch)
tree6a5e370a5878810018613d094cea47a8f9d8384d /llvm/lib/Transforms
parent0c17cbf790cde9ed33b3f225b460194d27b2021a (diff)
downloadbcm5719-llvm-3d4579829e85c108e729ade64d778e614b702e16.tar.gz
bcm5719-llvm-3d4579829e85c108e729ade64d778e614b702e16.zip
Fix an ordering bug in the scalarizer.
I've added a new test case that causes the scalarizer to try and use dead-and-erased values - caused by the basic blocks not being in domination order within the function. To fix this, instead of iterating through the blocks in function order, I walk them in reverse post order. Differential Revision: https://reviews.llvm.org/D52540 llvm-svn: 344128
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/Scalarizer.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/Scalarizer.cpp b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
index 34ed126155b..2f873abca66 100644
--- a/llvm/lib/Transforms/Scalar/Scalarizer.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
@@ -14,6 +14,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Analysis/VectorUtils.h"
@@ -289,8 +290,12 @@ bool Scalarizer::runOnFunction(Function &F) {
if (skipFunction(F))
return false;
assert(Gathered.empty() && Scattered.empty());
- for (BasicBlock &BB : F) {
- for (BasicBlock::iterator II = BB.begin(), IE = BB.end(); II != IE;) {
+
+ // To ensure we replace gathered components correctly we need to do an ordered
+ // traversal of the basic blocks in the function.
+ ReversePostOrderTraversal<BasicBlock *> RPOT(&F.getEntryBlock());
+ for (BasicBlock *BB : RPOT) {
+ for (BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE;) {
Instruction *I = &*II;
bool Done = visit(I);
++II;
OpenPOWER on IntegriCloud