From ceb465a8a4ce2101bd7dd50db99cbc6b82757bd6 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 12 Apr 2011 01:02:45 +0000 Subject: [PATCH] Consider ConstantAggregateZero as well as ConstantArray/Struct. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129338 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/ProfilingUtils.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp index 26b01e8c2fd..7435bc37fbe 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(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 dtors; if (GlobalVariable *GlobalDtors = Mod->getNamedGlobal("llvm.global_dtors")) { - ConstantArray *InitList = - cast(GlobalDtors->getInitializer()); - for (unsigned i = 0, e = InitList->getType()->getNumElements(); i != e; ++i) - dtors.push_back(cast(InitList->getOperand(i))); + if (ConstantArray *InitList = + dyn_cast(GlobalDtors->getInitializer())) { + for (unsigned i = 0, e = InitList->getType()->getNumElements(); + i != e; ++i) + dtors.push_back(cast(InitList->getOperand(i))); + } GlobalDtors->eraseFromParent(); } -- 2.34.1