[llvm] d857a81 - [VPlan] Use SetVector for VPExternalDefs to prevent non-determinism.

Huihui Zhang via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 30 12:11:22 PDT 2021


Author: Huihui Zhang
Date: 2021-03-30T12:10:56-07:00
New Revision: d857a81437cbd9066b29dffceec500e3ea1edc0e

URL: https://github.com/llvm/llvm-project/commit/d857a81437cbd9066b29dffceec500e3ea1edc0e
DIFF: https://github.com/llvm/llvm-project/commit/d857a81437cbd9066b29dffceec500e3ea1edc0e.diff

LOG: [VPlan] Use SetVector for VPExternalDefs to prevent non-determinism.

Use SetVector instead of SmallPtrSet for external definitions created for VPlan.
Doing this can help avoid non-determinism caused by iterating over unordered containers.

This bug was found with reverse iteration turning on,
 --extra-llvm-cmake-variables="-DLLVM_REVERSE_ITERATION=ON".
Failing LLVM-Unit test VPRecipeTest.dump.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D99544

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/VPlan.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index f27628572ce0a..05815d1084f2a 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1767,7 +1767,7 @@ class VPlan {
   // VPlan. External definitions must be immutable and hold a pointer to its
   // underlying IR that will be used to implement its structural comparison
   // (operators '==' and '<').
-  SmallPtrSet<VPValue *, 16> VPExternalDefs;
+  SetVector<VPValue *> VPExternalDefs;
 
   /// Represents the backedge taken count of the original loop, for folding
   /// the tail.
@@ -1835,9 +1835,7 @@ class VPlan {
 
   /// Add \p VPVal to the pool of external definitions if it's not already
   /// in the pool.
-  void addExternalDef(VPValue *VPVal) {
-    VPExternalDefs.insert(VPVal);
-  }
+  void addExternalDef(VPValue *VPVal) { VPExternalDefs.insert(VPVal); }
 
   void addVPValue(Value *V) {
     assert(V && "Trying to add a null Value to VPlan");


        


More information about the llvm-commits mailing list