llvm.org GIT mirror llvm / f50c6df
[ADCE] Fix non-deterministic behaviour due to iterating over a pointer set. Original patch by Yann Laigle-Chapuy Differential Revision: https://reviews.llvm.org/D64785 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366215 91177308-0d34-0410-b5e6-96231b3b80d8 Amara Emerson 3 months ago
1 changed file(s) with 8 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
1818 #include "llvm/ADT/GraphTraits.h"
1919 #include "llvm/ADT/MapVector.h"
2020 #include "llvm/ADT/PostOrderIterator.h"
21 #include "llvm/ADT/SetVector.h"
2122 #include "llvm/ADT/SmallPtrSet.h"
2223 #include "llvm/ADT/SmallVector.h"
2324 #include "llvm/ADT/Statistic.h"
134135 SmallPtrSet AliveScopes;
135136
136137 /// Set of blocks with not known to have live terminators.
137 SmallPtrSet BlocksWithDeadTerminators;
138 SmallSetVector BlocksWithDeadTerminators;
138139
139140 /// The set of blocks which we have determined whose control
140141 /// dependence sources must be live and which have not had
388389 // Mark the containing block live
389390 auto &BBInfo = *Info.Block;
390391 if (BBInfo.Terminator == I) {
391 BlocksWithDeadTerminators.erase(BBInfo.BB);
392 BlocksWithDeadTerminators.remove(BBInfo.BB);
392393 // For live terminators, mark destination blocks
393394 // live to preserve this control flow edges.
394395 if (!BBInfo.UnconditionalBranch)
477478 // which currently have dead terminators that are control
478479 // dependence sources of a block which is in NewLiveBlocks.
479480
481 const SmallPtrSet BWDT{
482 BlocksWithDeadTerminators.begin(),
483 BlocksWithDeadTerminators.end()
484 };
480485 SmallVector IDFBlocks;
481486 ReverseIDFCalculator IDFs(PDT);
482487 IDFs.setDefiningBlocks(NewLiveBlocks);
483 IDFs.setLiveInBlocks(BlocksWithDeadTerminators);
488 IDFs.setLiveInBlocks(BWDT);
484489 IDFs.calculate(IDFBlocks);
485490 NewLiveBlocks.clear();
486491