[llvm-commits] [llvm] r50331 - in /llvm/trunk/tools/bugpoint: CrashDebugger.cpp ExtractFunction.cpp

Chris Lattner sabre at nondot.org
Sun Apr 27 17:04:58 PDT 2008


Author: lattner
Date: Sun Apr 27 19:04:58 2008
New Revision: 50331

URL: http://llvm.org/viewvc/llvm-project?rev=50331&view=rev
Log:
several multiple-retval fixes for bugpoint.

Modified:
    llvm/trunk/tools/bugpoint/CrashDebugger.cpp
    llvm/trunk/tools/bugpoint/ExtractFunction.cpp

Modified: llvm/trunk/tools/bugpoint/CrashDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/CrashDebugger.cpp?rev=50331&r1=50330&r2=50331&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/CrashDebugger.cpp (original)
+++ llvm/trunk/tools/bugpoint/CrashDebugger.cpp Sun Apr 27 19:04:58 2008
@@ -14,7 +14,7 @@
 #include "BugDriver.h"
 #include "ToolRunner.h"
 #include "ListReducer.h"
-#include "llvm/Constant.h"
+#include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Instructions.h"
 #include "llvm/Module.h"
@@ -300,17 +300,16 @@
         for (succ_iterator SI = succ_begin(BB), E = succ_end(BB); SI != E; ++SI)
           (*SI)->removePredecessor(BB);
 
-        if (BB->getTerminator()->getType() != Type::VoidTy)
-          BB->getTerminator()->replaceAllUsesWith(
-                      Constant::getNullValue(BB->getTerminator()->getType()));
+        TerminatorInst *BBTerm = BB->getTerminator();
+        
+        if (isa<StructType>(BBTerm->getType()))
+           BBTerm->replaceAllUsesWith(UndefValue::get(BBTerm->getType()));
+        else if (BB->getTerminator()->getType() != Type::VoidTy)
+          BBTerm->replaceAllUsesWith(Constant::getNullValue(BBTerm->getType()));
 
-        // Delete the old terminator instruction...
+        // Replace the old terminator instruction.
         BB->getInstList().pop_back();
-
-        // Add a new return instruction of the appropriate type...
-        const Type *RetTy = BB->getParent()->getReturnType();
-        ReturnInst::Create(RetTy == Type::VoidTy ? 0 :
-                           Constant::getNullValue(RetTy), BB);
+        new UnreachableInst(BB);
       }
 
   // The CFG Simplifier pass may delete one of the basic blocks we are

Modified: llvm/trunk/tools/bugpoint/ExtractFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExtractFunction.cpp?rev=50331&r1=50330&r2=50331&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/ExtractFunction.cpp (original)
+++ llvm/trunk/tools/bugpoint/ExtractFunction.cpp Sun Apr 27 19:04:58 2008
@@ -71,7 +71,9 @@
   Instruction *TheInst = RI;              // Got the corresponding instruction!
 
   // If this instruction produces a value, replace any users with null values
-  if (TheInst->getType() != Type::VoidTy)
+  if (isa<StructType>(TheInst->getType()))
+    TheInst->replaceAllUsesWith(UndefValue::get(TheInst->getType()));
+  else if (TheInst->getType() != Type::VoidTy)
     TheInst->replaceAllUsesWith(Constant::getNullValue(TheInst->getType()));
 
   // Remove the instruction from the program.





More information about the llvm-commits mailing list