[llvm-commits] [llvm] r129338 - /llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp

Nick Lewycky nicholas at mxc.ca
Mon Apr 11 18:02:45 PDT 2011


Author: nicholas
Date: Mon Apr 11 20:02:45 2011
New Revision: 129338

URL: http://llvm.org/viewvc/llvm-project?rev=129338&view=rev
Log:
Consider ConstantAggregateZero as well as ConstantArray/Struct.

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp

Modified: llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp?rev=129338&r1=129337&r2=129338&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp Mon Apr 11 20:02:45 2011
@@ -110,7 +110,7 @@
                                    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 @@
   // 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();
   }
 





More information about the llvm-commits mailing list