X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fbugpoint%2FCrashDebugger.cpp;h=7dcbfe3c4a68a9a7a8e9e74ebfcd684eaaf46c7f;hb=8d3f36f05cb97efb1cc24a5c64d6c792651cd897;hp=dac8538662022ceb34d9a10a95b53652a5d50964;hpb=8ff70c2635bfd4e02c0140a5dc9ca909fffba35a;p=oota-llvm.git diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp index dac85386620..7dcbfe3c4a6 100644 --- a/tools/bugpoint/CrashDebugger.cpp +++ b/tools/bugpoint/CrashDebugger.cpp @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -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" @@ -125,13 +125,14 @@ bool ReduceCrashingGlobalVariables::TestGlobalVariables( std::vector& GVs) { // Clone the program to try hacking it apart... - Module *M = CloneModule(BD.getProgram()); + DenseMap ValueMap; + Module *M = CloneModule(BD.getProgram(), ValueMap); // Convert list to set for fast lookup... std::set GVSet; for (unsigned i = 0, e = GVs.size(); i != e; ++i) { - GlobalVariable* CMGV = M->getNamedGlobal(GVs[i]->getName()); + GlobalVariable* CMGV = cast(ValueMap[GVs[i]]); assert(CMGV && "Global Variable not in module?!"); GVSet.insert(CMGV); } @@ -299,17 +300,16 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector &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(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(); - new ReturnInst(RetTy == Type::VoidTy ? 0 : - Constant::getNullValue(RetTy), BB); + new UnreachableInst(BB); } // The CFG Simplifier pass may delete one of the basic blocks we are