Previously, all operands to Constant were themselves constant.

In the new world order, BlockAddress can have a BasicBlock operand.
This doesn't permute much, because if you have a ConstantExpr (or
anything more specific than Constant) we still know the operand has
to be a Constant.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85375 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2009-10-28 05:14:34 +00:00
parent 46b3abc9f7
commit 0eeb913aa1
7 changed files with 48 additions and 39 deletions

View File

@ -112,11 +112,11 @@ static bool OnlyUsedBy(Value *V, Value *Usr) {
static void RemoveDeadConstant(Constant *C) {
assert(C->use_empty() && "Constant is not dead!");
SmallPtrSet<Constant *, 4> Operands;
SmallPtrSet<Constant*, 4> Operands;
for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i)
if (isa<DerivedType>(C->getOperand(i)->getType()) &&
OnlyUsedBy(C->getOperand(i), C))
Operands.insert(C->getOperand(i));
Operands.insert(cast<Constant>(C->getOperand(i)));
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
if (!GV->hasLocalLinkage()) return; // Don't delete non static globals.
GV->eraseFromParent();
@ -126,7 +126,7 @@ static void RemoveDeadConstant(Constant *C) {
C->destroyConstant();
// If the constant referenced anything, see if we can delete it as well.
for (SmallPtrSet<Constant *, 4>::iterator OI = Operands.begin(),
for (SmallPtrSet<Constant*, 4>::iterator OI = Operands.begin(),
OE = Operands.end(); OI != OE; ++OI)
RemoveDeadConstant(*OI);
}
@ -305,8 +305,7 @@ bool StripDebugDeclare::runOnModule(Module &M) {
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
if (GV->hasLocalLinkage())
RemoveDeadConstant(GV);
}
else
} else
RemoveDeadConstant(C);
}