[PATCH] D64785: [ADCE] Fix non-deterministic behaviour due to iterating over a pointer set

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 16 08:24:04 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL366215: [ADCE] Fix non-deterministic behaviour due to iterating over a pointer set. (authored by aemerson, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D64785?vs=210032&id=210106#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64785/new/

https://reviews.llvm.org/D64785

Files:
  llvm/trunk/lib/Transforms/Scalar/ADCE.cpp


Index: llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
+++ llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
@@ -19,6 +19,7 @@
 #include "llvm/ADT/GraphTraits.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/PostOrderIterator.h"
+#include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Statistic.h"
@@ -135,7 +136,7 @@
   SmallPtrSet<const Metadata *, 32> AliveScopes;
 
   /// Set of blocks with not known to have live terminators.
-  SmallPtrSet<BasicBlock *, 16> BlocksWithDeadTerminators;
+  SmallSetVector<BasicBlock *, 16> BlocksWithDeadTerminators;
 
   /// The set of blocks which we have determined whose control
   /// dependence sources must be live and which have not had
@@ -389,7 +390,7 @@
   // Mark the containing block live
   auto &BBInfo = *Info.Block;
   if (BBInfo.Terminator == I) {
-    BlocksWithDeadTerminators.erase(BBInfo.BB);
+    BlocksWithDeadTerminators.remove(BBInfo.BB);
     // For live terminators, mark destination blocks
     // live to preserve this control flow edges.
     if (!BBInfo.UnconditionalBranch)
@@ -478,10 +479,14 @@
   // which currently have dead terminators that are control
   // dependence sources of a block which is in NewLiveBlocks.
 
+  const SmallPtrSet<BasicBlock *, 16> BWDT{
+      BlocksWithDeadTerminators.begin(),
+      BlocksWithDeadTerminators.end()
+  };
   SmallVector<BasicBlock *, 32> IDFBlocks;
   ReverseIDFCalculator IDFs(PDT);
   IDFs.setDefiningBlocks(NewLiveBlocks);
-  IDFs.setLiveInBlocks(BlocksWithDeadTerminators);
+  IDFs.setLiveInBlocks(BWDT);
   IDFs.calculate(IDFBlocks);
   NewLiveBlocks.clear();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64785.210106.patch
Type: text/x-patch
Size: 1761 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190716/85e12474/attachment.bin>


More information about the llvm-commits mailing list