<div dir="ltr"><div>Why is the first for loop not equivalent to the second?</div><div><br></div><div>Thanks,</div><div>Rob</div><div><br></div><div>===========================<br></div><div><br></div><div><div>for (GlobalVariable **i = Globals.begin(), **e = Globals.end(); i != e; ++i) {</div>
<div><span style="white-space:pre-wrap"> </span>GlobalVariable *GV = *i;</div></div><div><br></div><div> Constant *GEP = ConstantExpr::getGetElementPtr(...);<br></div><div> GV->replaceAllUsesWith(GEP);<br></div><div>
}</div>
<div><br></div><div>===========================</div><div><br></div><div><div><div>for (GlobalVariable **i = Globals.begin(), **e = Globals.end(); i != e; ++i) {</div><div><span style="white-space:pre-wrap"> </span>GlobalVariable *GV = *i;</div>
</div><div><br></div><div> Constant *GEP = ConstantExpr::getGetElementPtr(...);<br></div><div><br></div><div><div>for (Value::use_iterator ui = GV->use_begin(); ui != GV->use_end(); ++ui) {</div><div> if(User *u = dyn_cast < User > (*ui)) {</div>
<div> u->replaceUsesOfWith(GV, GEP);<br></div><div> }</div></div><div>}</div></div><div><br></div><div>===========================<br></div></div>