[PATCH] D131488: [TypePromotion] Don't delete Insns when iterating
Andre Vieira via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 11 01:50:42 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe524d61f35a3: [TypePromotion] Don't delete Insns when iterating (authored by avieira).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131488/new/
https://reviews.llvm.org/D131488
Files:
llvm/lib/CodeGen/TypePromotion.cpp
Index: llvm/lib/CodeGen/TypePromotion.cpp
===================================================================
--- llvm/lib/CodeGen/TypePromotion.cpp
+++ llvm/lib/CodeGen/TypePromotion.cpp
@@ -106,9 +106,9 @@
SetVector<Value *> &Sources;
SetVector<Instruction *> &Sinks;
SmallPtrSetImpl<Instruction *> &SafeWrap;
+ SmallPtrSetImpl<Instruction *> &InstsToRemove;
IntegerType *ExtTy = nullptr;
SmallPtrSet<Value *, 8> NewInsts;
- SmallPtrSet<Instruction *, 4> InstsToRemove;
DenseMap<Value *, SmallVector<Type *, 4>> TruncTysMap;
SmallPtrSet<Value *, 8> Promoted;
@@ -120,12 +120,12 @@
void Cleanup();
public:
- IRPromoter(LLVMContext &C, unsigned Width,
- SetVector<Value *> &visited, SetVector<Value *> &sources,
- SetVector<Instruction *> &sinks,
- SmallPtrSetImpl<Instruction *> &wrap)
- : Ctx(C), PromotedWidth(Width), Visited(visited),
- Sources(sources), Sinks(sinks), SafeWrap(wrap) {
+ IRPromoter(LLVMContext &C, unsigned Width, SetVector<Value *> &visited,
+ SetVector<Value *> &sources, SetVector<Instruction *> &sinks,
+ SmallPtrSetImpl<Instruction *> &wrap,
+ SmallPtrSetImpl<Instruction *> &instsToRemove)
+ : Ctx(C), PromotedWidth(Width), Visited(visited), Sources(sources),
+ Sinks(sinks), SafeWrap(wrap), InstsToRemove(instsToRemove) {
ExtTy = IntegerType::get(Ctx, PromotedWidth);
}
@@ -139,6 +139,7 @@
SmallPtrSet<Value *, 16> AllVisited;
SmallPtrSet<Instruction *, 8> SafeToPromote;
SmallPtrSet<Instruction *, 4> SafeWrap;
+ SmallPtrSet<Instruction *, 4> InstsToRemove;
// Does V have the same size result type as TypeSize.
bool EqualTypeSize(Value *V);
@@ -604,7 +605,6 @@
for (auto *I : InstsToRemove) {
LLVM_DEBUG(dbgs() << "IR Promotion: Removing " << *I << "\n");
I->dropAllReferences();
- I->eraseFromParent();
}
}
@@ -876,7 +876,7 @@
return false;
IRPromoter Promoter(*Ctx, PromotedWidth, CurrentVisited, Sources, Sinks,
- SafeWrap);
+ SafeWrap, InstsToRemove);
Promoter.Mutate();
return true;
}
@@ -942,6 +942,11 @@
}
}
}
+ if (!InstsToRemove.empty()) {
+ for (auto *I : InstsToRemove)
+ I->eraseFromParent();
+ InstsToRemove.clear();
+ }
}
AllVisited.clear();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131488.451772.patch
Type: text/x-patch
Size: 2376 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220811/3c30cb5c/attachment.bin>
More information about the llvm-commits
mailing list