Consider ConstantAggregateZero as well as ConstantArray/Struct.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129338 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nick Lewycky 2011-04-12 01:02:45 +00:00
parent bbfc3b3098
commit ceb465a8a4

View File

@ -110,7 +110,7 @@ void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum,
GlobalValue *CounterArray, bool beginning) {
// Insert the increment after any alloca or PHI instructions...
BasicBlock::iterator InsertPos = beginning ? BB->getFirstNonPHI() :
BB->getTerminator();
BB->getTerminator();
while (isa<AllocaInst>(InsertPos))
++InsertPos;
@ -151,10 +151,12 @@ void llvm::InsertProfilingShutdownCall(Function *Callee, Module *Mod) {
// delete it, to replace it with one that has a larger array type.
std::vector<Constant *> dtors;
if (GlobalVariable *GlobalDtors = Mod->getNamedGlobal("llvm.global_dtors")) {
ConstantArray *InitList =
cast<ConstantArray>(GlobalDtors->getInitializer());
for (unsigned i = 0, e = InitList->getType()->getNumElements(); i != e; ++i)
dtors.push_back(cast<Constant>(InitList->getOperand(i)));
if (ConstantArray *InitList =
dyn_cast<ConstantArray>(GlobalDtors->getInitializer())) {
for (unsigned i = 0, e = InitList->getType()->getNumElements();
i != e; ++i)
dtors.push_back(cast<Constant>(InitList->getOperand(i)));
}
GlobalDtors->eraseFromParent();
}