[FunctionAttrs] Extract a helper function for the core logic used to
[oota-llvm.git] / lib / Transforms / IPO / StripSymbols.cpp
index bcead02d80a2c6a649482583cbe96c0cfd282f77..a4f30c58f936b3f84c0b5f27ae0d5b90e18355aa 100644 (file)
@@ -142,9 +142,9 @@ static bool OnlyUsedBy(Value *V, Value *Usr) {
 static void RemoveDeadConstant(Constant *C) {
   assert(C->use_empty() && "Constant is not dead!");
   SmallPtrSet<Constant*, 4> Operands;
-  for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i)
-    if (OnlyUsedBy(C->getOperand(i), C))
-      Operands.insert(cast<Constant>(C->getOperand(i)));
+  for (Value *Op : C->operands())
+    if (OnlyUsedBy(Op, C))
+      Operands.insert(cast<Constant>(Op));
   if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
     if (!GV->hasLocalLinkage()) return;   // Don't delete non-static globals.
     GV->eraseFromParent();
@@ -305,10 +305,10 @@ bool StripDeadDebugInfo::runOnModule(Module &M) {
   SmallVector<Metadata *, 64> LiveSubprograms;
   DenseSet<const MDNode *> VisitedSet;
 
-  for (MDCompileUnit *DIC : F.compile_units()) {
+  for (DICompileUnit *DIC : F.compile_units()) {
     // Create our live subprogram list.
     bool SubprogramChange = false;
-    for (MDSubprogram *DISP : DIC->getSubprograms()) {
+    for (DISubprogram *DISP : DIC->getSubprograms()) {
       // Make sure we visit each subprogram only once.
       if (!VisitedSet.insert(DISP).second)
         continue;
@@ -322,7 +322,7 @@ bool StripDeadDebugInfo::runOnModule(Module &M) {
 
     // Create our live global variable list.
     bool GlobalVariableChange = false;
-    for (MDGlobalVariable *DIG : DIC->getGlobalVariables()) {
+    for (DIGlobalVariable *DIG : DIC->getGlobalVariables()) {
       // Make sure we only visit each global variable only once.
       if (!VisitedSet.insert(DIG).second)
         continue;