forked from OSchip/llvm-project
[SROA] Fix nondeterminism exposed by Simon's r299221.
Use a SmallSetSetVector instead of a SmallPtrSet as iterating over the latter is not stable ('<' relies on addresses). llvm-svn: 301599
This commit is contained in:
parent
a85572ebf0
commit
81a26da1e5
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "llvm/Transforms/Scalar/SROA.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Analysis/AssumptionCache.h"
|
||||
|
@ -2186,8 +2187,8 @@ class llvm::sroa::AllocaSliceRewriter
|
|||
Instruction *OldPtr;
|
||||
|
||||
// Track post-rewrite users which are PHI nodes and Selects.
|
||||
SmallPtrSetImpl<PHINode *> &PHIUsers;
|
||||
SmallPtrSetImpl<SelectInst *> &SelectUsers;
|
||||
SmallSetVector<PHINode *, 8> &PHIUsers;
|
||||
SmallSetVector<SelectInst *, 8> &SelectUsers;
|
||||
|
||||
// Utility IR builder, whose name prefix is setup for each visited use, and
|
||||
// the insertion point is set to point to the user.
|
||||
|
@ -2199,8 +2200,8 @@ public:
|
|||
uint64_t NewAllocaBeginOffset,
|
||||
uint64_t NewAllocaEndOffset, bool IsIntegerPromotable,
|
||||
VectorType *PromotableVecTy,
|
||||
SmallPtrSetImpl<PHINode *> &PHIUsers,
|
||||
SmallPtrSetImpl<SelectInst *> &SelectUsers)
|
||||
SmallSetVector<PHINode *, 8> &PHIUsers,
|
||||
SmallSetVector<SelectInst *, 8> &SelectUsers)
|
||||
: DL(DL), AS(AS), Pass(Pass), OldAI(OldAI), NewAI(NewAI),
|
||||
NewAllocaBeginOffset(NewAllocaBeginOffset),
|
||||
NewAllocaEndOffset(NewAllocaEndOffset),
|
||||
|
@ -3880,8 +3881,8 @@ AllocaInst *SROA::rewritePartition(AllocaInst &AI, AllocaSlices &AS,
|
|||
// fact scheduled for promotion.
|
||||
unsigned PPWOldSize = PostPromotionWorklist.size();
|
||||
unsigned NumUses = 0;
|
||||
SmallPtrSet<PHINode *, 8> PHIUsers;
|
||||
SmallPtrSet<SelectInst *, 8> SelectUsers;
|
||||
SmallSetVector<PHINode *, 8> PHIUsers;
|
||||
SmallSetVector<SelectInst *, 8> SelectUsers;
|
||||
|
||||
AllocaSliceRewriter Rewriter(DL, AS, *this, AI, *NewAI, P.beginOffset(),
|
||||
P.endOffset(), IsIntegerPromotable, VecTy,
|
||||
|
@ -3902,19 +3903,16 @@ AllocaInst *SROA::rewritePartition(AllocaInst &AI, AllocaSlices &AS,
|
|||
|
||||
// Now that we've processed all the slices in the new partition, check if any
|
||||
// PHIs or Selects would block promotion.
|
||||
for (SmallPtrSetImpl<PHINode *>::iterator I = PHIUsers.begin(),
|
||||
E = PHIUsers.end();
|
||||
I != E; ++I)
|
||||
if (!isSafePHIToSpeculate(**I)) {
|
||||
for (PHINode *PHI : PHIUsers)
|
||||
if (!isSafePHIToSpeculate(*PHI)) {
|
||||
Promotable = false;
|
||||
PHIUsers.clear();
|
||||
SelectUsers.clear();
|
||||
break;
|
||||
}
|
||||
for (SmallPtrSetImpl<SelectInst *>::iterator I = SelectUsers.begin(),
|
||||
E = SelectUsers.end();
|
||||
I != E; ++I)
|
||||
if (!isSafeSelectToSpeculate(**I)) {
|
||||
|
||||
for (SelectInst *Sel : SelectUsers)
|
||||
if (!isSafeSelectToSpeculate(*Sel)) {
|
||||
Promotable = false;
|
||||
PHIUsers.clear();
|
||||
SelectUsers.clear();
|
||||
|
|
Loading…
Reference in New Issue