[PATCH] D74534: [Float2Int] Make iteration over Roots deterministic

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 13 02:03:16 PST 2020


bjope created this revision.
Herald added a subscriber: mgrang.
Herald added a project: LLVM.

Use a SmallSetVector instead of a SmallPtrSet when collecting
and storing Roots.

The iteration order for a SmallPtrSet is not deterministic,
so in the past the order of items inserted in the WorkList
inside walkBackwards has been non-deterministic. This patch
intends to make the order of rewrites done in Float2Int
deterministic by changing the container for the Roots set.

The semantics result of the transformation should not be
any different afaict. But at least naming of IR variables
(when outputting the result as an ll file) should be more
stable now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74534

Files:
  llvm/include/llvm/Transforms/Scalar/Float2Int.h


Index: llvm/include/llvm/Transforms/Scalar/Float2Int.h
===================================================================
--- llvm/include/llvm/Transforms/Scalar/Float2Int.h
+++ llvm/include/llvm/Transforms/Scalar/Float2Int.h
@@ -16,6 +16,7 @@
 
 #include "llvm/ADT/EquivalenceClasses.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/SetVector.h"
 #include "llvm/IR/ConstantRange.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/Function.h"
@@ -30,7 +31,7 @@
   bool runImpl(Function &F, const DominatorTree &DT);
 
 private:
-  using RootSet = SmallPtrSet<Instruction *, 8>;
+  using RootSet = SmallSetVector<Instruction *, 8>;
 
   void findRoots(Function &F, const DominatorTree &DT,
                  RootSet &Roots);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74534.244362.patch
Type: text/x-patch
Size: 736 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200213/374f75dc/attachment.bin>


More information about the llvm-commits mailing list