Adjust to changes in APIs

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19958 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2005-02-01 01:23:31 +00:00
parent 5a87447286
commit d514d8294d
2 changed files with 10 additions and 16 deletions

View File

@@ -98,11 +98,11 @@ static bool ResolveFunctions(Module &M, std::vector<GlobalValue*> &Globals,
// functions and that the Old function has no varargs fns specified. In // functions and that the Old function has no varargs fns specified. In
// otherwords it's just <retty> (...) // otherwords it's just <retty> (...)
// //
if (!Old->use_empty()) { // Avoid making the CPR unless we really need it if (!Old->use_empty()) {
Value *Replacement = Concrete; Value *Replacement = Concrete;
if (Concrete->getType() != Old->getType()) if (Concrete->getType() != Old->getType())
Replacement = ConstantExpr::getCast(Concrete,Old->getType()); Replacement = ConstantExpr::getCast(Concrete, Old->getType());
NumResolved += Old->use_size(); NumResolved += Old->getNumUses();
Old->replaceAllUsesWith(Replacement); Old->replaceAllUsesWith(Replacement);
} }

View File

@@ -361,7 +361,8 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV) {
else else
assert(0 && "Unknown aggregate sequential type!"); assert(0 && "Unknown aggregate sequential type!");
if (NumElements > 16 && GV->use_size() > 16) return 0; // It's not worth it. if (NumElements > 16 && GV->getNumUses() > 16)
return 0; // It's not worth it.
NewGlobals.reserve(NumElements); NewGlobals.reserve(NumElements);
for (unsigned i = 0, e = NumElements; i != e; ++i) { for (unsigned i = 0, e = NumElements; i != e; ++i) {
Constant *In = getAggregateConstantElement(Init, Constant *In = getAggregateConstantElement(Init,
@@ -614,17 +615,11 @@ static void ConstantPropUsersOf(Value *V) {
if (Constant *NewC = ConstantFoldInstruction(I)) { if (Constant *NewC = ConstantFoldInstruction(I)) {
I->replaceAllUsesWith(NewC); I->replaceAllUsesWith(NewC);
// Back up UI to avoid invalidating it! // Advance UI to the next non-I use to avoid invalidating it!
bool AtBegin = false; // Instructions could multiply use V.
if (UI == V->use_begin()) while (UI != E && *UI == I)
AtBegin = true;
else
--UI;
I->eraseFromParent();
if (AtBegin)
UI = V->use_begin();
else
++UI; ++UI;
I->eraseFromParent();
} }
} }
@@ -683,8 +678,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
while (!GV->use_empty()) while (!GV->use_empty())
if (LoadInst *LI = dyn_cast<LoadInst>(GV->use_back())) { if (LoadInst *LI = dyn_cast<LoadInst>(GV->use_back())) {
while (!LI->use_empty()) { while (!LI->use_empty()) {
// FIXME: the iterator should expose a getUse() method. Use &LoadUse = LI->use_begin().getUse();
Use &LoadUse = *(const iplist<Use>::iterator&)LI->use_begin();
if (!isa<SetCondInst>(LoadUse.getUser())) if (!isa<SetCondInst>(LoadUse.getUser()))
LoadUse = RepValue; LoadUse = RepValue;
else { else {