X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fbugpoint%2FCrashDebugger.cpp;h=7dcbfe3c4a68a9a7a8e9e74ebfcd684eaaf46c7f;hb=963a97f1a365c8d09ca681e922371f9ec3473ee8;hp=b597d8256d5a52b8c017e6eef83e41bcf29f4a73;hpb=ef9b9a793949469cdaa4ab6d0173136229dcab7b;p=oota-llvm.git diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp index b597d8256d5..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" @@ -22,7 +22,6 @@ #include "llvm/PassManager.h" #include "llvm/ValueSymbolTable.h" #include "llvm/Analysis/Verifier.h" -#include "llvm/Bytecode/Writer.h" #include "llvm/Support/CFG.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/Cloning.h" @@ -71,7 +70,7 @@ ReducePassList::doTest(std::vector &Prefix, BD.Program = ParseInputFile(PrefixOutput.toString()); if (BD.Program == 0) { - std::cerr << BD.getToolName() << ": Error reading bytecode file '" + std::cerr << BD.getToolName() << ": Error reading bitcode file '" << PrefixOutput << "'!\n"; exit(1); } @@ -126,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); } @@ -194,7 +194,7 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector &Funcs) { //if main isn't present, claim there is no problem if (KeepMain && find(Funcs.begin(), Funcs.end(), - BD.getProgram()->getMainFunction()) == Funcs.end()) + BD.getProgram()->getFunction("main")) == Funcs.end()) return false; // Clone the program to try hacking it apart... @@ -300,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 @@ -397,7 +396,7 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) { ReduceCrashingGlobalVariables(BD, TestFn).reduceList(GVs); if (GVs.size() < OldSize) - BD.EmitProgressBytecode("reduced-global-variables"); + BD.EmitProgressBitcode("reduced-global-variables"); } } } @@ -418,7 +417,7 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) { ReduceCrashingFunctions(BD, TestFn).reduceList(Functions); if (Functions.size() < OldSize) - BD.EmitProgressBytecode("reduced-function"); + BD.EmitProgressBitcode("reduced-function"); } // Attempt to delete entire basic blocks at a time to speed up @@ -509,7 +508,7 @@ ExitLoops: } } - BD.EmitProgressBytecode("reduced-simplified"); + BD.EmitProgressBitcode("reduced-simplified"); return false; } @@ -533,7 +532,7 @@ bool BugDriver::debugOptimizerCrash(const std::string &ID) { << (PassesToRun.size() == 1 ? ": " : "es: ") << getPassesString(PassesToRun) << '\n'; - EmitProgressBytecode(ID); + EmitProgressBitcode(ID); return DebugACrash(*this, TestForOptimizerCrash); }