[llvm-commits] [llvm] r54778 - /llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp
Matthijs Kooijman
matthijs at stdin.nl
Thu Aug 14 08:03:05 PDT 2008
Author: matthijs
Date: Thu Aug 14 10:03:05 2008
New Revision: 54778
URL: http://llvm.org/viewvc/llvm-project?rev=54778&view=rev
Log:
Replace two for loops with while(!X->use_empty()) loops. This prevents
invalidating the iterator by deleting the current use. This fixes a segfault on
64 bit linux reported in PR2675.
Also remove an unneeded if.
Modified:
llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp
Modified: llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp?rev=54778&r1=54777&r2=54778&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp Thu Aug 14 10:03:05 2008
@@ -258,10 +258,8 @@
// ParamAttrs - Keep track of the parameter attributes for the arguments.
SmallVector<ParamAttrsWithIndex, 8> ArgAttrsVec;
- for (Value::use_iterator FUI = F->use_begin(), FUE = F->use_end();
- FUI != FUE;) {
- CallSite CS = CallSite::get(*FUI);
- ++FUI;
+ while (!F->use_empty()) {
+ CallSite CS = CallSite::get(*F->use_begin());
Instruction *Call = CS.getInstruction();
const PAListPtr &PAL = F->getParamAttrs();
@@ -317,12 +315,12 @@
assert (Idx && "Unexpected getelementptr index!");
Value *GR = ExtractValueInst::Create(New, Idx->getZExtValue(),
"evi", UGEP);
- for (Value::use_iterator GI = UGEP->use_begin(),
- GE = UGEP->use_end(); GI != GE; ++GI) {
- if (LoadInst *L = dyn_cast<LoadInst>(*GI)) {
- L->replaceAllUsesWith(GR);
- L->eraseFromParent();
- }
+ while(!UGEP->use_empty()) {
+ // isSafeToUpdateAllCallers has checked that all GEP uses are
+ // LoadInsts
+ LoadInst *L = cast<LoadInst>(*UGEP->use_begin());
+ L->replaceAllUsesWith(GR);
+ L->eraseFromParent();
}
UGEP->eraseFromParent();
}
More information about the llvm-commits
mailing list