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 | ceb465a8a4ce2101bd7dd50db99cbc6b82757bd6 (patch) | |
tree | 8ef695476ad3a12c8f975df4e7b704e9ed273a41 /lib/Transforms/Instrumentation/ProfilingUtils.cpp | |
parent | bbfc3b30986ff89487350cade99ea7c90e2c8165 (diff) |
Consider ConstantAggregateZero as well as ConstantArray/Struct.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129338 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Instrumentation/ProfilingUtils.cpp')
-rw-r--r-- | lib/Transforms/Instrumentation/ProfilingUtils.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp index 26b01e8c2f..7435bc37fb 100644 --- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp +++ b/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(); } |