diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-04-12 01:02:45 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-04-12 01:02:45 +0000 |
commit | fbc5a4004c1d79e08a3d2e3b9dd1eba94e12e320 (patch) | |
tree | 04a171e01db6cc3c4e97a522048e2bee8790d70b /llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp | |
parent | 32f44bd0fcf93d99dd0010bd7724c6520b716db2 (diff) | |
download | bcm5719-llvm-fbc5a4004c1d79e08a3d2e3b9dd1eba94e12e320.tar.gz bcm5719-llvm-fbc5a4004c1d79e08a3d2e3b9dd1eba94e12e320.zip |
Consider ConstantAggregateZero as well as ConstantArray/Struct.
llvm-svn: 129338
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp index 26b01e8c2fd..7435bc37fbe 100644 --- a/llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp +++ b/llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp @@ -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(); } |