Fix non-determinism issue in SLP
authorJulien Lerouge <jlerouge@apple.com>
Tue, 13 Jan 2015 19:45:52 +0000 (19:45 +0000)
committerJulien Lerouge <jlerouge@apple.com>
Tue, 13 Jan 2015 19:45:52 +0000 (19:45 +0000)
The issue was introduced in r214638:

+  for (auto &BSIter : BlocksSchedules) {
+    scheduleBlock(BSIter.second.get());
+  }

Because BlocksSchedules is a DenseMap with BasicBlock* keys, blocks are
scheduled in non-deterministic order, resulting in unpredictable IR.

Patch by Daniel Reynaud!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225821 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Vectorize/SLPVectorizer.cpp

index 9281bcb2c512d955d43da6cf524d1f9e9318b51c..24d02b0060b10285e868ea38a5c0802c1bef3ed9 100644 (file)
@@ -857,7 +857,7 @@ private:
   };
 
   /// Attaches the BlockScheduling structures to basic blocks.
-  DenseMap<BasicBlock *, std::unique_ptr<BlockScheduling>> BlocksSchedules;
+  MapVector<BasicBlock *, std::unique_ptr<BlockScheduling>> BlocksSchedules;
 
   /// Performs the "real" scheduling. Done before vectorization is actually
   /// performed in a basic block.