diff options
Diffstat (limited to 'llvm/tools/bugpoint/CrashDebugger.cpp')
| -rw-r--r-- | llvm/tools/bugpoint/CrashDebugger.cpp | 396 |
1 files changed, 198 insertions, 198 deletions
diff --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp index f6b35f5fd53..649cac7c681 100644 --- a/llvm/tools/bugpoint/CrashDebugger.cpp +++ b/llvm/tools/bugpoint/CrashDebugger.cpp @@ -14,9 +14,9 @@ #include "BugDriver.h" #include "ListReducer.h" #include "ToolRunner.h" -#include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringSet.h" +#include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/IR/CFG.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" @@ -36,52 +36,49 @@ using namespace llvm; namespace { - cl::opt<bool> - KeepMain("keep-main", - cl::desc("Force function reduction to keep main"), - cl::init(false)); - cl::opt<bool> - NoGlobalRM ("disable-global-remove", - cl::desc("Do not remove global variables"), - cl::init(false)); - - cl::opt<bool> - ReplaceFuncsWithNull("replace-funcs-with-null", - cl::desc("When stubbing functions, replace all uses will null"), - cl::init(false)); - cl::opt<bool> - DontReducePassList("disable-pass-list-reduction", - cl::desc("Skip pass list reduction steps"), - cl::init(false)); - - cl::opt<bool> NoNamedMDRM("disable-namedmd-remove", - cl::desc("Do not remove global named metadata"), - cl::init(false)); - cl::opt<bool> VerboseErrors("verbose-errors", +cl::opt<bool> KeepMain("keep-main", + cl::desc("Force function reduction to keep main"), + cl::init(false)); +cl::opt<bool> NoGlobalRM("disable-global-remove", + cl::desc("Do not remove global variables"), + cl::init(false)); + +cl::opt<bool> ReplaceFuncsWithNull( + "replace-funcs-with-null", + cl::desc("When stubbing functions, replace all uses will null"), + cl::init(false)); +cl::opt<bool> DontReducePassList("disable-pass-list-reduction", + cl::desc("Skip pass list reduction steps"), + cl::init(false)); + +cl::opt<bool> NoNamedMDRM("disable-namedmd-remove", + cl::desc("Do not remove global named metadata"), + cl::init(false)); +cl::opt<bool> VerboseErrors("verbose-errors", cl::desc("Print the output of crashing program"), cl::init(false)); } namespace llvm { - class ReducePassList : public ListReducer<std::string> { - BugDriver &BD; - public: - ReducePassList(BugDriver &bd) : BD(bd) {} - - // doTest - Return true iff running the "removed" passes succeeds, and - // running the "Kept" passes fail when run on the output of the "removed" - // passes. If we return true, we update the current module of bugpoint. - // - TestResult doTest(std::vector<std::string> &Removed, - std::vector<std::string> &Kept, - std::string &Error) override; - }; +class ReducePassList : public ListReducer<std::string> { + BugDriver &BD; + +public: + ReducePassList(BugDriver &bd) : BD(bd) {} + + // doTest - Return true iff running the "removed" passes succeeds, and + // running the "Kept" passes fail when run on the output of the "removed" + // passes. If we return true, we update the current module of bugpoint. + // + TestResult doTest(std::vector<std::string> &Removed, + std::vector<std::string> &Kept, + std::string &Error) override; +}; } ReducePassList::TestResult ReducePassList::doTest(std::vector<std::string> &Prefix, - std::vector<std::string> &Suffix, - std::string &Error) { + std::vector<std::string> &Suffix, std::string &Error) { std::string PrefixOutput; Module *OrigProgram = nullptr; if (!Prefix.empty()) { @@ -101,11 +98,11 @@ ReducePassList::doTest(std::vector<std::string> &Prefix, sys::fs::remove(PrefixOutput); } - outs() << "Checking to see if these passes crash: " - << getPassesString(Suffix) << ": "; + outs() << "Checking to see if these passes crash: " << getPassesString(Suffix) + << ": "; if (BD.runPasses(BD.getProgram(), Suffix)) { - delete OrigProgram; // The suffix crashes alone... + delete OrigProgram; // The suffix crashes alone... return KeepSuffix; } @@ -118,44 +115,44 @@ ReducePassList::doTest(std::vector<std::string> &Prefix, } namespace { - /// ReduceCrashingGlobalVariables - This works by removing the global - /// variable's initializer and seeing if the program still crashes. If it - /// does, then we keep that program and try again. - /// - class ReduceCrashingGlobalVariables : public ListReducer<GlobalVariable*> { - BugDriver &BD; - bool (*TestFn)(const BugDriver &, Module *); - public: - ReduceCrashingGlobalVariables(BugDriver &bd, - bool (*testFn)(const BugDriver &, Module *)) +/// ReduceCrashingGlobalVariables - This works by removing the global +/// variable's initializer and seeing if the program still crashes. If it +/// does, then we keep that program and try again. +/// +class ReduceCrashingGlobalVariables : public ListReducer<GlobalVariable *> { + BugDriver &BD; + bool (*TestFn)(const BugDriver &, Module *); + +public: + ReduceCrashingGlobalVariables(BugDriver &bd, + bool (*testFn)(const BugDriver &, Module *)) : BD(bd), TestFn(testFn) {} - TestResult doTest(std::vector<GlobalVariable*> &Prefix, - std::vector<GlobalVariable*> &Kept, - std::string &Error) override { - if (!Kept.empty() && TestGlobalVariables(Kept)) - return KeepSuffix; - if (!Prefix.empty() && TestGlobalVariables(Prefix)) - return KeepPrefix; - return NoFailure; - } + TestResult doTest(std::vector<GlobalVariable *> &Prefix, + std::vector<GlobalVariable *> &Kept, + std::string &Error) override { + if (!Kept.empty() && TestGlobalVariables(Kept)) + return KeepSuffix; + if (!Prefix.empty() && TestGlobalVariables(Prefix)) + return KeepPrefix; + return NoFailure; + } - bool TestGlobalVariables(std::vector<GlobalVariable*> &GVs); - }; + bool TestGlobalVariables(std::vector<GlobalVariable *> &GVs); +}; } -bool -ReduceCrashingGlobalVariables::TestGlobalVariables( - std::vector<GlobalVariable*> &GVs) { +bool ReduceCrashingGlobalVariables::TestGlobalVariables( + std::vector<GlobalVariable *> &GVs) { // Clone the program to try hacking it apart... ValueToValueMapTy VMap; Module *M = CloneModule(BD.getProgram(), VMap).release(); // Convert list to set for fast lookup... - std::set<GlobalVariable*> GVSet; + std::set<GlobalVariable *> GVSet; for (unsigned i = 0, e = GVs.size(); i != e; ++i) { - GlobalVariable* CMGV = cast<GlobalVariable>(VMap[GVs[i]]); + GlobalVariable *CMGV = cast<GlobalVariable>(VMap[GVs[i]]); assert(CMGV && "Global Variable not in module?!"); GVSet.insert(CMGV); } @@ -175,7 +172,7 @@ ReduceCrashingGlobalVariables::TestGlobalVariables( // Try running the hacked up program... if (TestFn(BD, M)) { - BD.setNewProgram(M); // It crashed, keep the trimmed version... + BD.setNewProgram(M); // It crashed, keep the trimmed version... // Make sure to use global variable pointers that point into the now-current // module. @@ -188,45 +185,47 @@ ReduceCrashingGlobalVariables::TestGlobalVariables( } namespace { - /// ReduceCrashingFunctions reducer - This works by removing functions and - /// seeing if the program still crashes. If it does, then keep the newer, - /// smaller program. - /// - class ReduceCrashingFunctions : public ListReducer<Function*> { - BugDriver &BD; - bool (*TestFn)(const BugDriver &, Module *); - public: - ReduceCrashingFunctions(BugDriver &bd, - bool (*testFn)(const BugDriver &, Module *)) +/// ReduceCrashingFunctions reducer - This works by removing functions and +/// seeing if the program still crashes. If it does, then keep the newer, +/// smaller program. +/// +class ReduceCrashingFunctions : public ListReducer<Function *> { + BugDriver &BD; + bool (*TestFn)(const BugDriver &, Module *); + +public: + ReduceCrashingFunctions(BugDriver &bd, + bool (*testFn)(const BugDriver &, Module *)) : BD(bd), TestFn(testFn) {} - TestResult doTest(std::vector<Function*> &Prefix, - std::vector<Function*> &Kept, - std::string &Error) override { - if (!Kept.empty() && TestFuncs(Kept)) - return KeepSuffix; - if (!Prefix.empty() && TestFuncs(Prefix)) - return KeepPrefix; - return NoFailure; - } + TestResult doTest(std::vector<Function *> &Prefix, + std::vector<Function *> &Kept, + std::string &Error) override { + if (!Kept.empty() && TestFuncs(Kept)) + return KeepSuffix; + if (!Prefix.empty() && TestFuncs(Prefix)) + return KeepPrefix; + return NoFailure; + } - bool TestFuncs(std::vector<Function*> &Prefix); - }; + bool TestFuncs(std::vector<Function *> &Prefix); +}; } -static void RemoveFunctionReferences(Module *M, const char* Name) { +static void RemoveFunctionReferences(Module *M, const char *Name) { auto *UsedVar = M->getGlobalVariable(Name, true); - if (!UsedVar || !UsedVar->hasInitializer()) return; + if (!UsedVar || !UsedVar->hasInitializer()) + return; if (isa<ConstantAggregateZero>(UsedVar->getInitializer())) { assert(UsedVar->use_empty()); UsedVar->eraseFromParent(); return; } auto *OldUsedVal = cast<ConstantArray>(UsedVar->getInitializer()); - std::vector<Constant*> Used; - for(Value *V : OldUsedVal->operand_values()) { + std::vector<Constant *> Used; + for (Value *V : OldUsedVal->operand_values()) { Constant *Op = cast<Constant>(V->stripPointerCasts()); - if(!Op->isNullValue()) { + if (!Op->isNullValue()) { Used.push_back(cast<Constant>(V)); } } @@ -237,7 +236,7 @@ static void RemoveFunctionReferences(Module *M, const char* Name) { UsedVar->setInitializer(NewUsedVal); } -bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) { +bool ReduceCrashingFunctions::TestFuncs(std::vector<Function *> &Funcs) { // If main isn't present, claim there is no problem. if (KeepMain && !is_contained(Funcs, BD.getProgram()->getFunction("main"))) return false; @@ -247,7 +246,7 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) { Module *M = CloneModule(BD.getProgram(), VMap).release(); // Convert list to set for fast lookup... - std::set<Function*> Functions; + std::set<Function *> Functions; for (unsigned i = 0, e = Funcs.size(); i != e; ++i) { Function *CMF = cast<Function>(VMap[Funcs[i]]); assert(CMF && "Function not in module?!"); @@ -266,7 +265,7 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) { if (!I.isDeclaration() && !Functions.count(&I)) DeleteFunctionBody(&I); } else { - std::vector<GlobalValue*> ToRemove; + std::vector<GlobalValue *> ToRemove; // First, remove aliases to functions we're about to purge. for (GlobalAlias &Alias : M->aliases()) { GlobalObject *Root = Alias.getBaseObject(); @@ -308,7 +307,7 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) { } // Try running the hacked up program... if (TestFn(BD, M)) { - BD.setNewProgram(M); // It crashed, keep the trimmed version... + BD.setNewProgram(M); // It crashed, keep the trimmed version... // Make sure to use function pointers that point into the now-current // module. @@ -350,7 +349,7 @@ void simpleSimplifyCfg(Function &F, SmallVectorImpl<BasicBlock *> &BBs) { // The dead BB's may be in a dead cycle or otherwise have references to each // other. Because of this, we have to drop all references first, then delete // them all at once. - for (auto *BB : Unreachable) { + for (auto *BB : Unreachable) { for (BasicBlock *Successor : successors(&*BB)) if (Visited.count(Successor)) Successor->removePredecessor(&*BB); @@ -359,46 +358,48 @@ void simpleSimplifyCfg(Function &F, SmallVectorImpl<BasicBlock *> &BBs) { for (auto *BB : Unreachable) BB->eraseFromParent(); } - /// ReduceCrashingBlocks reducer - This works by setting the terminators of - /// all terminators except the specified basic blocks to a 'ret' instruction, - /// then running the simplify-cfg pass. This has the effect of chopping up - /// the CFG really fast which can reduce large functions quickly. - /// - class ReduceCrashingBlocks : public ListReducer<const BasicBlock*> { - BugDriver &BD; - bool (*TestFn)(const BugDriver &, Module *); - public: - ReduceCrashingBlocks(BugDriver &BD, - bool (*testFn)(const BugDriver &, Module *)) +/// ReduceCrashingBlocks reducer - This works by setting the terminators of +/// all terminators except the specified basic blocks to a 'ret' instruction, +/// then running the simplify-cfg pass. This has the effect of chopping up +/// the CFG really fast which can reduce large functions quickly. +/// +class ReduceCrashingBlocks : public ListReducer<const BasicBlock *> { + BugDriver &BD; + bool (*TestFn)(const BugDriver &, Module *); + +public: + ReduceCrashingBlocks(BugDriver &BD, + bool (*testFn)(const BugDriver &, Module *)) : BD(BD), TestFn(testFn) {} - TestResult doTest(std::vector<const BasicBlock*> &Prefix, - std::vector<const BasicBlock*> &Kept, - std::string &Error) override { - if (!Kept.empty() && TestBlocks(Kept)) - return KeepSuffix; - if (!Prefix.empty() && TestBlocks(Prefix)) - return KeepPrefix; - return NoFailure; - } + TestResult doTest(std::vector<const BasicBlock *> &Prefix, + std::vector<const BasicBlock *> &Kept, + std::string &Error) override { + if (!Kept.empty() && TestBlocks(Kept)) + return KeepSuffix; + if (!Prefix.empty() && TestBlocks(Prefix)) + return KeepPrefix; + return NoFailure; + } - bool TestBlocks(std::vector<const BasicBlock*> &Prefix); - }; + bool TestBlocks(std::vector<const BasicBlock *> &Prefix); +}; } -bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) { +bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock *> &BBs) { // Clone the program to try hacking it apart... ValueToValueMapTy VMap; Module *M = CloneModule(BD.getProgram(), VMap).release(); // Convert list to set for fast lookup... - SmallPtrSet<BasicBlock*, 8> Blocks; + SmallPtrSet<BasicBlock *, 8> Blocks; for (unsigned i = 0, e = BBs.size(); i != e; ++i) Blocks.insert(cast<BasicBlock>(VMap[BBs[i]])); outs() << "Checking for crash with only these blocks:"; unsigned NumPrint = Blocks.size(); - if (NumPrint > 10) NumPrint = 10; + if (NumPrint > 10) + NumPrint = 10; for (unsigned i = 0, e = NumPrint; i != e; ++i) outs() << " " << BBs[i]->getName(); if (NumPrint < Blocks.size()) @@ -431,13 +432,13 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) { // a "persistent mapping" by turning basic blocks into <function, name> pairs. // This won't work well if blocks are unnamed, but that is just the risk we // have to take. - std::vector<std::pair<std::string, std::string> > BlockInfo; + std::vector<std::pair<std::string, std::string>> BlockInfo; for (BasicBlock *BB : Blocks) BlockInfo.emplace_back(BB->getParent()->getName(), BB->getName()); - + SmallVector<BasicBlock *, 16> ToProcess; - for (auto &F :*M) { + for (auto &F : *M) { for (auto &BB : F) if (!Blocks.count(&BB)) ToProcess.push_back(&BB); @@ -454,10 +455,10 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) { exit(1); } M = New.release(); - + // Try running on the hacked up program... if (TestFn(BD, M)) { - BD.setNewProgram(M); // It crashed, keep the trimmed version... + BD.setNewProgram(M); // It crashed, keep the trimmed version... // Make sure to use basic block pointers that point into the now-current // module, and that they don't include any deleted blocks. @@ -466,13 +467,13 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) { for (unsigned i = 0, e = BlockInfo.size(); i != e; ++i) { Function *F = cast<Function>(GST.lookup(BlockInfo[i].first)); ValueSymbolTable &ST = F->getValueSymbolTable(); - Value* V = ST.lookup(BlockInfo[i].second); + Value *V = ST.lookup(BlockInfo[i].second); if (V && V->getType() == Type::getLabelTy(V->getContext())) BBs.push_back(cast<BasicBlock>(V)); } return true; } - delete M; // It didn't crash, try something else. + delete M; // It didn't crash, try something else. return false; } @@ -515,7 +516,7 @@ bool ReduceCrashingConditionals::TestBlocks( // Convert list to set for fast lookup... SmallPtrSet<const BasicBlock *, 8> Blocks; - for (const auto *BB: BBs) + for (const auto *BB : BBs) Blocks.insert(cast<BasicBlock>(VMap[BB])); outs() << "Checking for crash with changing conditionals to always jump to " @@ -530,7 +531,7 @@ bool ReduceCrashingConditionals::TestBlocks( outs() << ": "; // Loop over and delete any hack up any blocks that are not listed... - for (auto &F: *M) + for (auto &F : *M) for (auto &BB : F) if (!Blocks.count(&BB)) { auto *BR = dyn_cast<BranchInst>(BB.getTerminator()); @@ -549,7 +550,7 @@ bool ReduceCrashingConditionals::TestBlocks( BlockInfo.emplace_back(BB->getParent()->getName(), BB->getName()); SmallVector<BasicBlock *, 16> ToProcess; - for (auto &F :*M) { + for (auto &F : *M) { for (auto &BB : F) if (!Blocks.count(&BB)) ToProcess.push_back(&BB); @@ -596,12 +597,10 @@ class ReduceSimplifyCFG : public ListReducer<const BasicBlock *> { BugDriver &BD; bool (*TestFn)(const BugDriver &, Module *); TargetTransformInfo TTI; - + public: - ReduceSimplifyCFG(BugDriver &bd, - bool (*testFn)(const BugDriver &, Module *)) - : BD(bd), TestFn(testFn), TTI(bd.getProgram()->getDataLayout()) - {} + ReduceSimplifyCFG(BugDriver &bd, bool (*testFn)(const BugDriver &, Module *)) + : BD(bd), TestFn(testFn), TTI(bd.getProgram()->getDataLayout()) {} TestResult doTest(std::vector<const BasicBlock *> &Prefix, std::vector<const BasicBlock *> &Kept, @@ -617,15 +616,14 @@ public: }; } -bool ReduceSimplifyCFG::TestBlocks( - std::vector<const BasicBlock *> &BBs) { +bool ReduceSimplifyCFG::TestBlocks(std::vector<const BasicBlock *> &BBs) { // Clone the program to try hacking it apart... ValueToValueMapTy VMap; Module *M = CloneModule(BD.getProgram(), VMap).release(); // Convert list to set for fast lookup... SmallPtrSet<const BasicBlock *, 8> Blocks; - for (const auto *BB: BBs) + for (const auto *BB : BBs) Blocks.insert(cast<BasicBlock>(VMap[BB])); outs() << "Checking for crash with CFG simplifying:"; @@ -638,23 +636,22 @@ bool ReduceSimplifyCFG::TestBlocks( outs() << "... <" << Blocks.size() << " total>"; outs() << ": "; - // The following may destroy some blocks, so we save them first + // The following may destroy some blocks, so we save them first std::vector<std::pair<std::string, std::string>> BlockInfo; for (const BasicBlock *BB : Blocks) BlockInfo.emplace_back(BB->getParent()->getName(), BB->getName()); - // Loop over and delete any hack up any blocks that are not listed... - for (auto &F: *M) - // Loop over all of the basic blocks and remove them if they are unneeded. - for (Function::iterator BBIt = F.begin(); BBIt != F.end(); ) { - if (!Blocks.count(&*BBIt)) { - ++BBIt; - continue; - } - SimplifyCFG(&*BBIt++, TTI, 1); - } + for (auto &F : *M) + // Loop over all of the basic blocks and remove them if they are unneeded. + for (Function::iterator BBIt = F.begin(); BBIt != F.end();) { + if (!Blocks.count(&*BBIt)) { + ++BBIt; + continue; + } + SimplifyCFG(&*BBIt++, TTI, 1); + } // Verify we didn't break anything std::vector<std::string> Passes; Passes.push_back("verify"); @@ -674,7 +671,7 @@ bool ReduceSimplifyCFG::TestBlocks( // module, and that they don't include any deleted blocks. BBs.clear(); const ValueSymbolTable &GST = M->getValueSymbolTable(); - for (auto &BI : BlockInfo){ + for (auto &BI : BlockInfo) { auto *F = cast<Function>(GST.lookup(BI.first)); ValueSymbolTable &ST = F->getValueSymbolTable(); Value *V = ST.lookup(BI.second); @@ -688,39 +685,40 @@ bool ReduceSimplifyCFG::TestBlocks( } namespace { - /// ReduceCrashingInstructions reducer - This works by removing the specified - /// non-terminator instructions and replacing them with undef. - /// - class ReduceCrashingInstructions : public ListReducer<const Instruction*> { - BugDriver &BD; - bool (*TestFn)(const BugDriver &, Module *); - public: - ReduceCrashingInstructions(BugDriver &bd, - bool (*testFn)(const BugDriver &, Module *)) +/// ReduceCrashingInstructions reducer - This works by removing the specified +/// non-terminator instructions and replacing them with undef. +/// +class ReduceCrashingInstructions : public ListReducer<const Instruction *> { + BugDriver &BD; + bool (*TestFn)(const BugDriver &, Module *); + +public: + ReduceCrashingInstructions(BugDriver &bd, + bool (*testFn)(const BugDriver &, Module *)) : BD(bd), TestFn(testFn) {} - TestResult doTest(std::vector<const Instruction*> &Prefix, - std::vector<const Instruction*> &Kept, - std::string &Error) override { - if (!Kept.empty() && TestInsts(Kept)) - return KeepSuffix; - if (!Prefix.empty() && TestInsts(Prefix)) - return KeepPrefix; - return NoFailure; - } + TestResult doTest(std::vector<const Instruction *> &Prefix, + std::vector<const Instruction *> &Kept, + std::string &Error) override { + if (!Kept.empty() && TestInsts(Kept)) + return KeepSuffix; + if (!Prefix.empty() && TestInsts(Prefix)) + return KeepPrefix; + return NoFailure; + } - bool TestInsts(std::vector<const Instruction*> &Prefix); - }; + bool TestInsts(std::vector<const Instruction *> &Prefix); +}; } -bool ReduceCrashingInstructions::TestInsts(std::vector<const Instruction*> - &Insts) { +bool ReduceCrashingInstructions::TestInsts( + std::vector<const Instruction *> &Insts) { // Clone the program to try hacking it apart... ValueToValueMapTy VMap; Module *M = CloneModule(BD.getProgram(), VMap).release(); // Convert list to set for fast lookup... - SmallPtrSet<Instruction*, 32> Instructions; + SmallPtrSet<Instruction *, 32> Instructions; for (unsigned i = 0, e = Insts.size(); i != e; ++i) { assert(!isa<TerminatorInst>(Insts[i])); Instructions.insert(cast<Instruction>(VMap[Insts[i]])); @@ -751,7 +749,7 @@ bool ReduceCrashingInstructions::TestInsts(std::vector<const Instruction*> // Try running on the hacked up program... if (TestFn(BD, M)) { - BD.setNewProgram(M); // It crashed, keep the trimmed version... + BD.setNewProgram(M); // It crashed, keep the trimmed version... // Make sure to use instruction pointers that point into the now-current // module, and that they don't include any deleted blocks. @@ -760,7 +758,7 @@ bool ReduceCrashingInstructions::TestInsts(std::vector<const Instruction*> Insts.push_back(Inst); return true; } - delete M; // It didn't crash, try something else. + delete M; // It didn't crash, try something else. return false; } @@ -910,7 +908,8 @@ bool ReduceCrashingNamedMDOps::TestNamedMDOps( } static void ReduceGlobalInitializers(BugDriver &BD, - bool (*TestFn)(const BugDriver &, Module *), + bool (*TestFn)(const BugDriver &, + Module *), std::string &Error) { if (BD.getProgram()->global_begin() != BD.getProgram()->global_end()) { // Now try to reduce the number of global variable initializers in the @@ -928,28 +927,29 @@ static void ReduceGlobalInitializers(BugDriver &BD, } if (!DeletedInit) { - delete M; // No change made... + delete M; // No change made... } else { // See if the program still causes a crash... outs() << "\nChecking to see if we can delete global inits: "; - if (TestFn(BD, M)) { // Still crashes? + if (TestFn(BD, M)) { // Still crashes? BD.setNewProgram(M); outs() << "\n*** Able to remove all global initializers!\n"; - } else { // No longer crashes? + } else { // No longer crashes? outs() << " - Removing all global inits hides problem!\n"; delete M; - std::vector<GlobalVariable*> GVs; + std::vector<GlobalVariable *> GVs; for (Module::global_iterator I = BD.getProgram()->global_begin(), - E = BD.getProgram()->global_end(); I != E; ++I) + E = BD.getProgram()->global_end(); + I != E; ++I) if (I->hasInitializer()) GVs.push_back(&*I); if (GVs.size() > 1 && !BugpointIsInterrupted) { outs() << "\n*** Attempting to reduce the number of global " - << "variables in the testcase\n"; + << "variables in the testcase\n"; unsigned OldSize = GVs.size(); ReduceCrashingGlobalVariables(BD, TestFn).reduceList(GVs, Error); @@ -969,7 +969,7 @@ static void ReduceInsts(BugDriver &BD, // Attempt to delete instructions using bisection. This should help out nasty // cases with large basic blocks where the problem is at one end. if (!BugpointIsInterrupted) { - std::vector<const Instruction*> Insts; + std::vector<const Instruction *> Insts; for (const Function &F : *BD.getProgram()) for (const BasicBlock &BB : F) for (const Instruction &I : BB) @@ -1002,7 +1002,8 @@ static void ReduceInsts(BugDriver &BD, // function, attempting to delete them. unsigned CurInstructionNum = 0; for (Module::const_iterator FI = BD.getProgram()->begin(), - E = BD.getProgram()->end(); FI != E; ++FI) + E = BD.getProgram()->end(); + FI != E; ++FI) if (!FI->isDeclaration()) for (Function::const_iterator BI = FI->begin(), E = FI->end(); BI != E; ++BI) @@ -1027,7 +1028,7 @@ static void ReduceInsts(BugDriver &BD, // to reduce the testcase... BD.setNewProgram(M.release()); InstructionsToSkipBeforeDeleting = CurInstructionNum; - goto TryAgain; // I wish I had a multi-level break here! + goto TryAgain; // I wish I had a multi-level break here! } } } @@ -1041,7 +1042,6 @@ static void ReduceInsts(BugDriver &BD, BD.EmitProgressBitcode(BD.getProgram(), "reduced-instructions"); } - /// DebugACrash - Given a predicate that determines whether a component crashes /// on a program, try to destructively reduce the program while still keeping /// the predicate true. @@ -1054,14 +1054,14 @@ static bool DebugACrash(BugDriver &BD, ReduceGlobalInitializers(BD, TestFn, Error); // Now try to reduce the number of functions in the module to something small. - std::vector<Function*> Functions; + std::vector<Function *> Functions; for (Function &F : *BD.getProgram()) if (!F.isDeclaration()) Functions.push_back(&F); if (Functions.size() > 1 && !BugpointIsInterrupted) { outs() << "\n*** Attempting to reduce the number of functions " - "in the testcase\n"; + "in the testcase\n"; unsigned OldSize = Functions.size(); ReduceCrashingFunctions(BD, TestFn).reduceList(Functions, Error); @@ -1073,7 +1073,7 @@ static bool DebugACrash(BugDriver &BD, // Attempt to change conditional branches into unconditional branches to // eliminate blocks. if (!DisableSimplifyCFG && !BugpointIsInterrupted) { - std::vector<const BasicBlock*> Blocks; + std::vector<const BasicBlock *> Blocks; for (Function &F : *BD.getProgram()) for (BasicBlock &BB : F) Blocks.push_back(&BB); @@ -1090,7 +1090,7 @@ static bool DebugACrash(BugDriver &BD, // shrinks the code dramatically quickly // if (!DisableSimplifyCFG && !BugpointIsInterrupted) { - std::vector<const BasicBlock*> Blocks; + std::vector<const BasicBlock *> Blocks; for (Function &F : *BD.getProgram()) for (BasicBlock &BB : F) Blocks.push_back(&BB); @@ -1101,7 +1101,7 @@ static bool DebugACrash(BugDriver &BD, } if (!DisableSimplifyCFG & !BugpointIsInterrupted) { - std::vector<const BasicBlock*> Blocks; + std::vector<const BasicBlock *> Blocks; for (Function &F : *BD.getProgram()) for (BasicBlock &BB : F) Blocks.push_back(&BB); @@ -1110,7 +1110,7 @@ static bool DebugACrash(BugDriver &BD, if (Blocks.size() < OldSize) BD.EmitProgressBitcode(BD.getProgram(), "reduced-simplifycfg"); } - + // Attempt to delete instructions using bisection. This should help out nasty // cases with large basic blocks where the problem is at one end. if (!BugpointIsInterrupted) @@ -1147,7 +1147,7 @@ static bool DebugACrash(BugDriver &BD, // Find out if the pass still crashes on the cleaned up program... if (TestFn(BD, M)) { - BD.setNewProgram(M); // Yup, it does, keep the reduced version... + BD.setNewProgram(M); // Yup, it does, keep the reduced version... } else { delete M; } @@ -1194,7 +1194,7 @@ static bool TestForCodeGenCrash(const BugDriver &BD, Module *M) { errs() << Error << "\n"; else errs() << "<crash>\n"; - return true; // Tool is still crashing. + return true; // Tool is still crashing. } errs() << '\n'; return false; |

