do something dumb, and inefficient, but more complete.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9542
91177308-0d34-0410-b5e6-
96231b3b80d8
bool IPCP::run(Module &M) {
bool Changed = false;
bool IPCP::run(Module &M) {
bool Changed = false;
- for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
- if (!I->isExternal() && I->hasInternalLinkage())
- Changed |= processFunction(*I);
+ bool LocalChange = true;
+
+ // FIXME: instead of using smart algorithms, we just iterate until we stop
+ // making changes.
+ while (LocalChange) {
+ LocalChange = false;
+ for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
+ if (!I->isExternal() && I->hasInternalLinkage())
+ LocalChange |= processFunction(*I);
+ Changed |= LocalChange;
+ }
// If we got to this point, there is a constant argument!
assert(NumNonconstant != ArgumentConstants.size());
Function::aiterator AI = F.abegin();
// If we got to this point, there is a constant argument!
assert(NumNonconstant != ArgumentConstants.size());
Function::aiterator AI = F.abegin();
+ bool MadeChange = false;
for (unsigned i = 0, e = ArgumentConstants.size(); i != e; ++i, ++AI)
// Do we have a constant argument!?
for (unsigned i = 0, e = ArgumentConstants.size(); i != e; ++i, ++AI)
// Do we have a constant argument!?
- if (!ArgumentConstants[i].second) {
+ if (!ArgumentConstants[i].second && !AI->use_empty()) {
assert(ArgumentConstants[i].first && "Unknown constant value!");
Value *V = ArgumentConstants[i].first;
if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V))
V = CPR->getValue();
AI->replaceAllUsesWith(V);
++NumArgumentsProped;
assert(ArgumentConstants[i].first && "Unknown constant value!");
Value *V = ArgumentConstants[i].first;
if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V))
V = CPR->getValue();
AI->replaceAllUsesWith(V);
++NumArgumentsProped;