several multiple-retval fixes for bugpoint.
authorChris Lattner <sabre@nondot.org>
Mon, 28 Apr 2008 00:04:58 +0000 (00:04 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 28 Apr 2008 00:04:58 +0000 (00:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50331 91177308-0d34-0410-b5e6-96231b3b80d8

tools/bugpoint/CrashDebugger.cpp
tools/bugpoint/ExtractFunction.cpp

index d86d1c5969c6af6b8332632cd7b993c383f28e11..7dcbfe3c4a68a9a7a8e9e74ebfcd684eaaf46c7f 100644 (file)
@@ -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 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
         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
index 906826e0e5bd1ceb0144194081135e258f277451..ca8a279153fe62321a058c6c8bf429496bc5fe99 100644 (file)
@@ -71,7 +71,9 @@ Module *BugDriver::deleteInstructionFromProgram(const Instruction *I,
   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.