Verify functions as they are produced if -debug is specified. Reduce
authorChris Lattner <sabre@nondot.org>
Sun, 14 Mar 2004 03:17:22 +0000 (03:17 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 14 Mar 2004 03:17:22 +0000 (03:17 +0000)
curly braceage

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12378 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/CodeExtractor.cpp

index 7de300668069cbca1dd5ef9cfd35c667d9851a22..cbe9858aa448e61e1f0ac7dca73d56236808469a 100644 (file)
@@ -20,6 +20,7 @@
 #include "llvm/Module.h"
 #include "llvm/Pass.h"
 #include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Analysis/Verifier.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 #include "llvm/Transforms/Utils/FunctionUtils.h"
 #include "Support/Debug.h"
@@ -324,13 +325,10 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
   for (unsigned i = 0, e = inputs.size(); i != e; ++i) {
     std::vector<User*> Users(inputs[i]->use_begin(), inputs[i]->use_end());
     for (std::vector<User*>::iterator use = Users.begin(), useE = Users.end();
-         use != useE; ++use) {
-      if (Instruction* inst = dyn_cast<Instruction>(*use)) {
-        if (contains(code, inst->getParent())) {
+         use != useE; ++use)
+      if (Instruction* inst = dyn_cast<Instruction>(*use))
+        if (contains(code, inst->getParent()))
           inst->replaceUsesOfWith(inputs[i], getFunctionArg(newFunction, i));
-        }
-      }
-    }
   }
 
   // Rewrite branches to basic blocks outside of the loop to new dummy blocks
@@ -563,6 +561,7 @@ Function *CodeExtractor::ExtractCodeRegion(const std::vector<BasicBlock*> &code)
 
   moveCodeToFunction(code, newFunction);
 
+  DEBUG(if (verifyFunction(*newFunction)) abort());
   return newFunction;
 }