From d857a81437cbd9066b29dffceec500e3ea1edc0e Mon Sep 17 00:00:00 2001 From: Huihui Zhang Date: Tue, 30 Mar 2021 12:10:44 -0700 Subject: [PATCH] [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 --- llvm/lib/Transforms/Vectorize/VPlan.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h index f276285..05815d1 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 VPExternalDefs; + SetVector VPExternalDefs; /// Represents the backedge taken count of the original loop, for folding /// the tail. @@ -1835,9 +1835,7 @@ public: /// 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"); -- 2.7.4