File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -1870,6 +1870,7 @@ bool postProcessBuiltinReturningStruct(Function *F) {
1870
1870
LLVMContext *Context = &M->getContext ();
1871
1871
std::string Name = F->getName ().str ();
1872
1872
F->setName (Name + " .old" );
1873
+ SmallVector<Instruction *, 32 > InstToRemove;
1873
1874
for (auto *U : F->users ()) {
1874
1875
if (auto *CI = dyn_cast<CallInst>(U)) {
1875
1876
auto *ST = cast<StoreInst>(*(CI->user_begin ()));
@@ -1887,12 +1888,14 @@ bool postProcessBuiltinReturningStruct(Function *F) {
1887
1888
Args.insert (Args.begin (), ST->getPointerOperand ());
1888
1889
auto *NewCI = CallInst::Create (NewF, Args, CI->getName (), CI);
1889
1890
NewCI->setCallingConv (CI->getCallingConv ());
1890
- ST->dropAllReferences ();
1891
- ST->eraseFromParent ();
1892
- CI->dropAllReferences ();
1893
- CI->eraseFromParent ();
1891
+ InstToRemove.push_back (ST);
1892
+ InstToRemove.push_back (CI);
1894
1893
}
1895
1894
}
1895
+ for (auto *Inst : InstToRemove) {
1896
+ Inst->dropAllReferences ();
1897
+ Inst->eraseFromParent ();
1898
+ }
1896
1899
F->dropAllReferences ();
1897
1900
F->eraseFromParent ();
1898
1901
return true ;
You can’t perform that action at this time.
0 commit comments