1 //===- CrashDebugger.cpp - Debug compilation crashes ----------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file defines the bugpoint internals that narrow down compilation crashes 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "BugDriver.h" 15 #include "ListReducer.h" 16 #include "ToolRunner.h" 17 #include "llvm/ADT/SmallPtrSet.h" 18 #include "llvm/ADT/StringSet.h" 19 #include "llvm/Analysis/TargetTransformInfo.h" 20 #include "llvm/IR/CFG.h" 21 #include "llvm/IR/Constants.h" 22 #include "llvm/IR/DerivedTypes.h" 23 #include "llvm/IR/Instructions.h" 24 #include "llvm/IR/LegacyPassManager.h" 25 #include "llvm/IR/Module.h" 26 #include "llvm/IR/ValueSymbolTable.h" 27 #include "llvm/IR/Verifier.h" 28 #include "llvm/Pass.h" 29 #include "llvm/Support/CommandLine.h" 30 #include "llvm/Support/FileUtilities.h" 31 #include "llvm/Transforms/Scalar.h" 32 #include "llvm/Transforms/Utils/BasicBlockUtils.h" 33 #include "llvm/Transforms/Utils/Cloning.h" 34 #include "llvm/Transforms/Utils/Local.h" 35 #include <set> 36 using namespace llvm; 37 38 namespace { 39 cl::opt<bool> KeepMain("keep-main", 40 cl::desc("Force function reduction to keep main"), 41 cl::init(false)); 42 cl::opt<bool> NoGlobalRM("disable-global-remove", 43 cl::desc("Do not remove global variables"), 44 cl::init(false)); 45 46 cl::opt<bool> ReplaceFuncsWithNull( 47 "replace-funcs-with-null", 48 cl::desc("When stubbing functions, replace all uses will null"), 49 cl::init(false)); 50 cl::opt<bool> DontReducePassList("disable-pass-list-reduction", 51 cl::desc("Skip pass list reduction steps"), 52 cl::init(false)); 53 54 cl::opt<bool> NoNamedMDRM("disable-namedmd-remove", 55 cl::desc("Do not remove global named metadata"), 56 cl::init(false)); 57 cl::opt<bool> VerboseErrors("verbose-errors", 58 cl::desc("Print the output of crashing program"), 59 cl::init(false)); 60 } 61 62 namespace llvm { 63 class ReducePassList : public ListReducer<std::string> { 64 BugDriver &BD; 65 66 public: 67 ReducePassList(BugDriver &bd) : BD(bd) {} 68 69 // Return true iff running the "removed" passes succeeds, and running the 70 // "Kept" passes fail when run on the output of the "removed" passes. If we 71 // return true, we update the current module of bugpoint. 72 Expected<TestResult> doTest(std::vector<std::string> &Removed, 73 std::vector<std::string> &Kept) override; 74 }; 75 } 76 77 Expected<ReducePassList::TestResult> 78 ReducePassList::doTest(std::vector<std::string> &Prefix, 79 std::vector<std::string> &Suffix) { 80 std::string PrefixOutput; 81 Module *OrigProgram = nullptr; 82 if (!Prefix.empty()) { 83 outs() << "Checking to see if these passes crash: " 84 << getPassesString(Prefix) << ": "; 85 if (BD.runPasses(BD.getProgram(), Prefix, PrefixOutput)) 86 return KeepPrefix; 87 88 OrigProgram = BD.Program; 89 90 BD.Program = parseInputFile(PrefixOutput, BD.getContext()).release(); 91 if (BD.Program == nullptr) { 92 errs() << BD.getToolName() << ": Error reading bitcode file '" 93 << PrefixOutput << "'!\n"; 94 exit(1); 95 } 96 sys::fs::remove(PrefixOutput); 97 } 98 99 outs() << "Checking to see if these passes crash: " << getPassesString(Suffix) 100 << ": "; 101 102 if (BD.runPasses(BD.getProgram(), Suffix)) { 103 delete OrigProgram; // The suffix crashes alone... 104 return KeepSuffix; 105 } 106 107 // Nothing failed, restore state... 108 if (OrigProgram) { 109 delete BD.Program; 110 BD.Program = OrigProgram; 111 } 112 return NoFailure; 113 } 114 115 namespace { 116 /// ReduceCrashingGlobalVariables - This works by removing the global 117 /// variable's initializer and seeing if the program still crashes. If it 118 /// does, then we keep that program and try again. 119 /// 120 class ReduceCrashingGlobalVariables : public ListReducer<GlobalVariable *> { 121 BugDriver &BD; 122 bool (*TestFn)(const BugDriver &, Module *); 123 124 public: 125 ReduceCrashingGlobalVariables(BugDriver &bd, 126 bool (*testFn)(const BugDriver &, Module *)) 127 : BD(bd), TestFn(testFn) {} 128 129 Expected<TestResult> doTest(std::vector<GlobalVariable *> &Prefix, 130 std::vector<GlobalVariable *> &Kept) override { 131 if (!Kept.empty() && TestGlobalVariables(Kept)) 132 return KeepSuffix; 133 if (!Prefix.empty() && TestGlobalVariables(Prefix)) 134 return KeepPrefix; 135 return NoFailure; 136 } 137 138 bool TestGlobalVariables(std::vector<GlobalVariable *> &GVs); 139 }; 140 } 141 142 bool ReduceCrashingGlobalVariables::TestGlobalVariables( 143 std::vector<GlobalVariable *> &GVs) { 144 // Clone the program to try hacking it apart... 145 ValueToValueMapTy VMap; 146 Module *M = CloneModule(BD.getProgram(), VMap).release(); 147 148 // Convert list to set for fast lookup... 149 std::set<GlobalVariable *> GVSet; 150 151 for (unsigned i = 0, e = GVs.size(); i != e; ++i) { 152 GlobalVariable *CMGV = cast<GlobalVariable>(VMap[GVs[i]]); 153 assert(CMGV && "Global Variable not in module?!"); 154 GVSet.insert(CMGV); 155 } 156 157 outs() << "Checking for crash with only these global variables: "; 158 PrintGlobalVariableList(GVs); 159 outs() << ": "; 160 161 // Loop over and delete any global variables which we aren't supposed to be 162 // playing with... 163 for (GlobalVariable &I : M->globals()) 164 if (I.hasInitializer() && !GVSet.count(&I)) { 165 DeleteGlobalInitializer(&I); 166 I.setLinkage(GlobalValue::ExternalLinkage); 167 I.setComdat(nullptr); 168 } 169 170 // Try running the hacked up program... 171 if (TestFn(BD, M)) { 172 BD.setNewProgram(M); // It crashed, keep the trimmed version... 173 174 // Make sure to use global variable pointers that point into the now-current 175 // module. 176 GVs.assign(GVSet.begin(), GVSet.end()); 177 return true; 178 } 179 180 delete M; 181 return false; 182 } 183 184 namespace { 185 /// ReduceCrashingFunctions reducer - This works by removing functions and 186 /// seeing if the program still crashes. If it does, then keep the newer, 187 /// smaller program. 188 /// 189 class ReduceCrashingFunctions : public ListReducer<Function *> { 190 BugDriver &BD; 191 bool (*TestFn)(const BugDriver &, Module *); 192 193 public: 194 ReduceCrashingFunctions(BugDriver &bd, 195 bool (*testFn)(const BugDriver &, Module *)) 196 : BD(bd), TestFn(testFn) {} 197 198 Expected<TestResult> doTest(std::vector<Function *> &Prefix, 199 std::vector<Function *> &Kept) override { 200 if (!Kept.empty() && TestFuncs(Kept)) 201 return KeepSuffix; 202 if (!Prefix.empty() && TestFuncs(Prefix)) 203 return KeepPrefix; 204 return NoFailure; 205 } 206 207 bool TestFuncs(std::vector<Function *> &Prefix); 208 }; 209 } 210 211 static void RemoveFunctionReferences(Module *M, const char *Name) { 212 auto *UsedVar = M->getGlobalVariable(Name, true); 213 if (!UsedVar || !UsedVar->hasInitializer()) 214 return; 215 if (isa<ConstantAggregateZero>(UsedVar->getInitializer())) { 216 assert(UsedVar->use_empty()); 217 UsedVar->eraseFromParent(); 218 return; 219 } 220 auto *OldUsedVal = cast<ConstantArray>(UsedVar->getInitializer()); 221 std::vector<Constant *> Used; 222 for (Value *V : OldUsedVal->operand_values()) { 223 Constant *Op = cast<Constant>(V->stripPointerCasts()); 224 if (!Op->isNullValue()) { 225 Used.push_back(cast<Constant>(V)); 226 } 227 } 228 auto *NewValElemTy = OldUsedVal->getType()->getElementType(); 229 auto *NewValTy = ArrayType::get(NewValElemTy, Used.size()); 230 auto *NewUsedVal = ConstantArray::get(NewValTy, Used); 231 UsedVar->mutateType(NewUsedVal->getType()->getPointerTo()); 232 UsedVar->setInitializer(NewUsedVal); 233 } 234 235 bool ReduceCrashingFunctions::TestFuncs(std::vector<Function *> &Funcs) { 236 // If main isn't present, claim there is no problem. 237 if (KeepMain && !is_contained(Funcs, BD.getProgram()->getFunction("main"))) 238 return false; 239 240 // Clone the program to try hacking it apart... 241 ValueToValueMapTy VMap; 242 Module *M = CloneModule(BD.getProgram(), VMap).release(); 243 244 // Convert list to set for fast lookup... 245 std::set<Function *> Functions; 246 for (unsigned i = 0, e = Funcs.size(); i != e; ++i) { 247 Function *CMF = cast<Function>(VMap[Funcs[i]]); 248 assert(CMF && "Function not in module?!"); 249 assert(CMF->getFunctionType() == Funcs[i]->getFunctionType() && "wrong ty"); 250 assert(CMF->getName() == Funcs[i]->getName() && "wrong name"); 251 Functions.insert(CMF); 252 } 253 254 outs() << "Checking for crash with only these functions: "; 255 PrintFunctionList(Funcs); 256 outs() << ": "; 257 if (!ReplaceFuncsWithNull) { 258 // Loop over and delete any functions which we aren't supposed to be playing 259 // with... 260 for (Function &I : *M) 261 if (!I.isDeclaration() && !Functions.count(&I)) 262 DeleteFunctionBody(&I); 263 } else { 264 std::vector<GlobalValue *> ToRemove; 265 // First, remove aliases to functions we're about to purge. 266 for (GlobalAlias &Alias : M->aliases()) { 267 GlobalObject *Root = Alias.getBaseObject(); 268 Function *F = dyn_cast_or_null<Function>(Root); 269 if (F) { 270 if (Functions.count(F)) 271 // We're keeping this function. 272 continue; 273 } else if (Root->isNullValue()) { 274 // This referenced a globalalias that we've already replaced, 275 // so we still need to replace this alias. 276 } else if (!F) { 277 // Not a function, therefore not something we mess with. 278 continue; 279 } 280 281 PointerType *Ty = cast<PointerType>(Alias.getType()); 282 Constant *Replacement = ConstantPointerNull::get(Ty); 283 Alias.replaceAllUsesWith(Replacement); 284 ToRemove.push_back(&Alias); 285 } 286 287 for (Function &I : *M) { 288 if (!I.isDeclaration() && !Functions.count(&I)) { 289 PointerType *Ty = cast<PointerType>(I.getType()); 290 Constant *Replacement = ConstantPointerNull::get(Ty); 291 I.replaceAllUsesWith(Replacement); 292 ToRemove.push_back(&I); 293 } 294 } 295 296 for (auto *F : ToRemove) { 297 F->eraseFromParent(); 298 } 299 300 // Finally, remove any null members from any global intrinsic. 301 RemoveFunctionReferences(M, "llvm.used"); 302 RemoveFunctionReferences(M, "llvm.compiler.used"); 303 } 304 // Try running the hacked up program... 305 if (TestFn(BD, M)) { 306 BD.setNewProgram(M); // It crashed, keep the trimmed version... 307 308 // Make sure to use function pointers that point into the now-current 309 // module. 310 Funcs.assign(Functions.begin(), Functions.end()); 311 return true; 312 } 313 delete M; 314 return false; 315 } 316 317 namespace { 318 /// Simplify the CFG without completely destroying it. 319 /// This is not well defined, but basically comes down to "try to eliminate 320 /// unreachable blocks and constant fold terminators without deciding that 321 /// certain undefined behavior cuts off the program at the legs". 322 void simpleSimplifyCfg(Function &F, SmallVectorImpl<BasicBlock *> &BBs) { 323 if (F.empty()) 324 return; 325 326 for (auto *BB : BBs) { 327 ConstantFoldTerminator(BB); 328 MergeBlockIntoPredecessor(BB); 329 } 330 331 // Remove unreachable blocks 332 // removeUnreachableBlocks can't be used here, it will turn various 333 // undefined behavior into unreachables, but bugpoint was the thing that 334 // generated the undefined behavior, and we don't want it to kill the entire 335 // program. 336 SmallPtrSet<BasicBlock *, 16> Visited; 337 for (auto *BB : depth_first(&F.getEntryBlock())) 338 Visited.insert(BB); 339 340 SmallVector<BasicBlock *, 16> Unreachable; 341 for (auto &BB : F) 342 if (!Visited.count(&BB)) 343 Unreachable.push_back(&BB); 344 345 // The dead BB's may be in a dead cycle or otherwise have references to each 346 // other. Because of this, we have to drop all references first, then delete 347 // them all at once. 348 for (auto *BB : Unreachable) { 349 for (BasicBlock *Successor : successors(&*BB)) 350 if (Visited.count(Successor)) 351 Successor->removePredecessor(&*BB); 352 BB->dropAllReferences(); 353 } 354 for (auto *BB : Unreachable) 355 BB->eraseFromParent(); 356 } 357 /// ReduceCrashingBlocks reducer - This works by setting the terminators of 358 /// all terminators except the specified basic blocks to a 'ret' instruction, 359 /// then running the simplify-cfg pass. This has the effect of chopping up 360 /// the CFG really fast which can reduce large functions quickly. 361 /// 362 class ReduceCrashingBlocks : public ListReducer<const BasicBlock *> { 363 BugDriver &BD; 364 bool (*TestFn)(const BugDriver &, Module *); 365 366 public: 367 ReduceCrashingBlocks(BugDriver &BD, 368 bool (*testFn)(const BugDriver &, Module *)) 369 : BD(BD), TestFn(testFn) {} 370 371 Expected<TestResult> doTest(std::vector<const BasicBlock *> &Prefix, 372 std::vector<const BasicBlock *> &Kept) override { 373 if (!Kept.empty() && TestBlocks(Kept)) 374 return KeepSuffix; 375 if (!Prefix.empty() && TestBlocks(Prefix)) 376 return KeepPrefix; 377 return NoFailure; 378 } 379 380 bool TestBlocks(std::vector<const BasicBlock *> &Prefix); 381 }; 382 } 383 384 bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock *> &BBs) { 385 // Clone the program to try hacking it apart... 386 ValueToValueMapTy VMap; 387 Module *M = CloneModule(BD.getProgram(), VMap).release(); 388 389 // Convert list to set for fast lookup... 390 SmallPtrSet<BasicBlock *, 8> Blocks; 391 for (unsigned i = 0, e = BBs.size(); i != e; ++i) 392 Blocks.insert(cast<BasicBlock>(VMap[BBs[i]])); 393 394 outs() << "Checking for crash with only these blocks:"; 395 unsigned NumPrint = Blocks.size(); 396 if (NumPrint > 10) 397 NumPrint = 10; 398 for (unsigned i = 0, e = NumPrint; i != e; ++i) 399 outs() << " " << BBs[i]->getName(); 400 if (NumPrint < Blocks.size()) 401 outs() << "... <" << Blocks.size() << " total>"; 402 outs() << ": "; 403 404 // Loop over and delete any hack up any blocks that are not listed... 405 for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) 406 for (Function::iterator BB = I->begin(), E = I->end(); BB != E; ++BB) 407 if (!Blocks.count(&*BB) && BB->getTerminator()->getNumSuccessors()) { 408 // Loop over all of the successors of this block, deleting any PHI nodes 409 // that might include it. 410 for (succ_iterator SI = succ_begin(&*BB), E = succ_end(&*BB); SI != E; 411 ++SI) 412 (*SI)->removePredecessor(&*BB); 413 414 TerminatorInst *BBTerm = BB->getTerminator(); 415 if (BBTerm->isEHPad() || BBTerm->getType()->isTokenTy()) 416 continue; 417 if (!BBTerm->getType()->isVoidTy()) 418 BBTerm->replaceAllUsesWith(Constant::getNullValue(BBTerm->getType())); 419 420 // Replace the old terminator instruction. 421 BB->getInstList().pop_back(); 422 new UnreachableInst(BB->getContext(), &*BB); 423 } 424 425 // The CFG Simplifier pass may delete one of the basic blocks we are 426 // interested in. If it does we need to take the block out of the list. Make 427 // a "persistent mapping" by turning basic blocks into <function, name> pairs. 428 // This won't work well if blocks are unnamed, but that is just the risk we 429 // have to take. 430 std::vector<std::pair<std::string, std::string>> BlockInfo; 431 432 for (BasicBlock *BB : Blocks) 433 BlockInfo.emplace_back(BB->getParent()->getName(), BB->getName()); 434 435 SmallVector<BasicBlock *, 16> ToProcess; 436 for (auto &F : *M) { 437 for (auto &BB : F) 438 if (!Blocks.count(&BB)) 439 ToProcess.push_back(&BB); 440 simpleSimplifyCfg(F, ToProcess); 441 ToProcess.clear(); 442 } 443 // Verify we didn't break anything 444 std::vector<std::string> Passes; 445 Passes.push_back("verify"); 446 std::unique_ptr<Module> New = BD.runPassesOn(M, Passes); 447 delete M; 448 if (!New) { 449 errs() << "verify failed!\n"; 450 exit(1); 451 } 452 M = New.release(); 453 454 // Try running on the hacked up program... 455 if (TestFn(BD, M)) { 456 BD.setNewProgram(M); // It crashed, keep the trimmed version... 457 458 // Make sure to use basic block pointers that point into the now-current 459 // module, and that they don't include any deleted blocks. 460 BBs.clear(); 461 const ValueSymbolTable &GST = M->getValueSymbolTable(); 462 for (unsigned i = 0, e = BlockInfo.size(); i != e; ++i) { 463 Function *F = cast<Function>(GST.lookup(BlockInfo[i].first)); 464 ValueSymbolTable &ST = F->getValueSymbolTable(); 465 Value *V = ST.lookup(BlockInfo[i].second); 466 if (V && V->getType() == Type::getLabelTy(V->getContext())) 467 BBs.push_back(cast<BasicBlock>(V)); 468 } 469 return true; 470 } 471 delete M; // It didn't crash, try something else. 472 return false; 473 } 474 475 namespace { 476 /// ReduceCrashingConditionals reducer - This works by changing 477 /// conditional branches to unconditional ones, then simplifying the CFG 478 /// This has the effect of chopping up the CFG really fast which can reduce 479 /// large functions quickly. 480 /// 481 class ReduceCrashingConditionals : public ListReducer<const BasicBlock *> { 482 BugDriver &BD; 483 bool (*TestFn)(const BugDriver &, Module *); 484 bool Direction; 485 486 public: 487 ReduceCrashingConditionals(BugDriver &bd, 488 bool (*testFn)(const BugDriver &, Module *), 489 bool Direction) 490 : BD(bd), TestFn(testFn), Direction(Direction) {} 491 492 Expected<TestResult> doTest(std::vector<const BasicBlock *> &Prefix, 493 std::vector<const BasicBlock *> &Kept) override { 494 if (!Kept.empty() && TestBlocks(Kept)) 495 return KeepSuffix; 496 if (!Prefix.empty() && TestBlocks(Prefix)) 497 return KeepPrefix; 498 return NoFailure; 499 } 500 501 bool TestBlocks(std::vector<const BasicBlock *> &Prefix); 502 }; 503 } 504 505 bool ReduceCrashingConditionals::TestBlocks( 506 std::vector<const BasicBlock *> &BBs) { 507 // Clone the program to try hacking it apart... 508 ValueToValueMapTy VMap; 509 Module *M = CloneModule(BD.getProgram(), VMap).release(); 510 511 // Convert list to set for fast lookup... 512 SmallPtrSet<const BasicBlock *, 8> Blocks; 513 for (const auto *BB : BBs) 514 Blocks.insert(cast<BasicBlock>(VMap[BB])); 515 516 outs() << "Checking for crash with changing conditionals to always jump to " 517 << (Direction ? "true" : "false") << ":"; 518 unsigned NumPrint = Blocks.size(); 519 if (NumPrint > 10) 520 NumPrint = 10; 521 for (unsigned i = 0, e = NumPrint; i != e; ++i) 522 outs() << " " << BBs[i]->getName(); 523 if (NumPrint < Blocks.size()) 524 outs() << "... <" << Blocks.size() << " total>"; 525 outs() << ": "; 526 527 // Loop over and delete any hack up any blocks that are not listed... 528 for (auto &F : *M) 529 for (auto &BB : F) 530 if (!Blocks.count(&BB)) { 531 auto *BR = dyn_cast<BranchInst>(BB.getTerminator()); 532 if (!BR || !BR->isConditional()) 533 continue; 534 if (Direction) 535 BR->setCondition(ConstantInt::getTrue(BR->getContext())); 536 else 537 BR->setCondition(ConstantInt::getFalse(BR->getContext())); 538 } 539 540 // The following may destroy some blocks, so we save them first 541 std::vector<std::pair<std::string, std::string>> BlockInfo; 542 543 for (const BasicBlock *BB : Blocks) 544 BlockInfo.emplace_back(BB->getParent()->getName(), BB->getName()); 545 546 SmallVector<BasicBlock *, 16> ToProcess; 547 for (auto &F : *M) { 548 for (auto &BB : F) 549 if (!Blocks.count(&BB)) 550 ToProcess.push_back(&BB); 551 simpleSimplifyCfg(F, ToProcess); 552 ToProcess.clear(); 553 } 554 // Verify we didn't break anything 555 std::vector<std::string> Passes; 556 Passes.push_back("verify"); 557 std::unique_ptr<Module> New = BD.runPassesOn(M, Passes); 558 delete M; 559 if (!New) { 560 errs() << "verify failed!\n"; 561 exit(1); 562 } 563 M = New.release(); 564 565 // Try running on the hacked up program... 566 if (TestFn(BD, M)) { 567 BD.setNewProgram(M); // It crashed, keep the trimmed version... 568 569 // Make sure to use basic block pointers that point into the now-current 570 // module, and that they don't include any deleted blocks. 571 BBs.clear(); 572 const ValueSymbolTable &GST = M->getValueSymbolTable(); 573 for (auto &BI : BlockInfo) { 574 auto *F = cast<Function>(GST.lookup(BI.first)); 575 ValueSymbolTable &ST = F->getValueSymbolTable(); 576 Value *V = ST.lookup(BI.second); 577 if (V && V->getType() == Type::getLabelTy(V->getContext())) 578 BBs.push_back(cast<BasicBlock>(V)); 579 } 580 return true; 581 } 582 delete M; // It didn't crash, try something else. 583 return false; 584 } 585 586 namespace { 587 /// SimplifyCFG reducer - This works by calling SimplifyCFG on each basic block 588 /// in the program. 589 590 class ReduceSimplifyCFG : public ListReducer<const BasicBlock *> { 591 BugDriver &BD; 592 bool (*TestFn)(const BugDriver &, Module *); 593 TargetTransformInfo TTI; 594 595 public: 596 ReduceSimplifyCFG(BugDriver &bd, bool (*testFn)(const BugDriver &, Module *)) 597 : BD(bd), TestFn(testFn), TTI(bd.getProgram()->getDataLayout()) {} 598 599 Expected<TestResult> doTest(std::vector<const BasicBlock *> &Prefix, 600 std::vector<const BasicBlock *> &Kept) override { 601 if (!Kept.empty() && TestBlocks(Kept)) 602 return KeepSuffix; 603 if (!Prefix.empty() && TestBlocks(Prefix)) 604 return KeepPrefix; 605 return NoFailure; 606 } 607 608 bool TestBlocks(std::vector<const BasicBlock *> &Prefix); 609 }; 610 } 611 612 bool ReduceSimplifyCFG::TestBlocks(std::vector<const BasicBlock *> &BBs) { 613 // Clone the program to try hacking it apart... 614 ValueToValueMapTy VMap; 615 Module *M = CloneModule(BD.getProgram(), VMap).release(); 616 617 // Convert list to set for fast lookup... 618 SmallPtrSet<const BasicBlock *, 8> Blocks; 619 for (const auto *BB : BBs) 620 Blocks.insert(cast<BasicBlock>(VMap[BB])); 621 622 outs() << "Checking for crash with CFG simplifying:"; 623 unsigned NumPrint = Blocks.size(); 624 if (NumPrint > 10) 625 NumPrint = 10; 626 for (unsigned i = 0, e = NumPrint; i != e; ++i) 627 outs() << " " << BBs[i]->getName(); 628 if (NumPrint < Blocks.size()) 629 outs() << "... <" << Blocks.size() << " total>"; 630 outs() << ": "; 631 632 // The following may destroy some blocks, so we save them first 633 std::vector<std::pair<std::string, std::string>> BlockInfo; 634 635 for (const BasicBlock *BB : Blocks) 636 BlockInfo.emplace_back(BB->getParent()->getName(), BB->getName()); 637 638 // Loop over and delete any hack up any blocks that are not listed... 639 for (auto &F : *M) 640 // Loop over all of the basic blocks and remove them if they are unneeded. 641 for (Function::iterator BBIt = F.begin(); BBIt != F.end();) { 642 if (!Blocks.count(&*BBIt)) { 643 ++BBIt; 644 continue; 645 } 646 SimplifyCFG(&*BBIt++, TTI, 1); 647 } 648 // Verify we didn't break anything 649 std::vector<std::string> Passes; 650 Passes.push_back("verify"); 651 std::unique_ptr<Module> New = BD.runPassesOn(M, Passes); 652 delete M; 653 if (!New) { 654 errs() << "verify failed!\n"; 655 exit(1); 656 } 657 M = New.release(); 658 659 // Try running on the hacked up program... 660 if (TestFn(BD, M)) { 661 BD.setNewProgram(M); // It crashed, keep the trimmed version... 662 663 // Make sure to use basic block pointers that point into the now-current 664 // module, and that they don't include any deleted blocks. 665 BBs.clear(); 666 const ValueSymbolTable &GST = M->getValueSymbolTable(); 667 for (auto &BI : BlockInfo) { 668 auto *F = cast<Function>(GST.lookup(BI.first)); 669 ValueSymbolTable &ST = F->getValueSymbolTable(); 670 Value *V = ST.lookup(BI.second); 671 if (V && V->getType() == Type::getLabelTy(V->getContext())) 672 BBs.push_back(cast<BasicBlock>(V)); 673 } 674 return true; 675 } 676 delete M; // It didn't crash, try something else. 677 return false; 678 } 679 680 namespace { 681 /// ReduceCrashingInstructions reducer - This works by removing the specified 682 /// non-terminator instructions and replacing them with undef. 683 /// 684 class ReduceCrashingInstructions : public ListReducer<const Instruction *> { 685 BugDriver &BD; 686 bool (*TestFn)(const BugDriver &, Module *); 687 688 public: 689 ReduceCrashingInstructions(BugDriver &bd, 690 bool (*testFn)(const BugDriver &, Module *)) 691 : BD(bd), TestFn(testFn) {} 692 693 Expected<TestResult> doTest(std::vector<const Instruction *> &Prefix, 694 std::vector<const Instruction *> &Kept) override { 695 if (!Kept.empty() && TestInsts(Kept)) 696 return KeepSuffix; 697 if (!Prefix.empty() && TestInsts(Prefix)) 698 return KeepPrefix; 699 return NoFailure; 700 } 701 702 bool TestInsts(std::vector<const Instruction *> &Prefix); 703 }; 704 } 705 706 bool ReduceCrashingInstructions::TestInsts( 707 std::vector<const Instruction *> &Insts) { 708 // Clone the program to try hacking it apart... 709 ValueToValueMapTy VMap; 710 Module *M = CloneModule(BD.getProgram(), VMap).release(); 711 712 // Convert list to set for fast lookup... 713 SmallPtrSet<Instruction *, 32> Instructions; 714 for (unsigned i = 0, e = Insts.size(); i != e; ++i) { 715 assert(!isa<TerminatorInst>(Insts[i])); 716 Instructions.insert(cast<Instruction>(VMap[Insts[i]])); 717 } 718 719 outs() << "Checking for crash with only " << Instructions.size(); 720 if (Instructions.size() == 1) 721 outs() << " instruction: "; 722 else 723 outs() << " instructions: "; 724 725 for (Module::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) 726 for (Function::iterator FI = MI->begin(), FE = MI->end(); FI != FE; ++FI) 727 for (BasicBlock::iterator I = FI->begin(), E = FI->end(); I != E;) { 728 Instruction *Inst = &*I++; 729 if (!Instructions.count(Inst) && !isa<TerminatorInst>(Inst) && 730 !Inst->isEHPad() && !Inst->getType()->isTokenTy()) { 731 if (!Inst->getType()->isVoidTy()) 732 Inst->replaceAllUsesWith(UndefValue::get(Inst->getType())); 733 Inst->eraseFromParent(); 734 } 735 } 736 737 // Verify that this is still valid. 738 legacy::PassManager Passes; 739 Passes.add(createVerifierPass()); 740 Passes.run(*M); 741 742 // Try running on the hacked up program... 743 if (TestFn(BD, M)) { 744 BD.setNewProgram(M); // It crashed, keep the trimmed version... 745 746 // Make sure to use instruction pointers that point into the now-current 747 // module, and that they don't include any deleted blocks. 748 Insts.clear(); 749 for (Instruction *Inst : Instructions) 750 Insts.push_back(Inst); 751 return true; 752 } 753 delete M; // It didn't crash, try something else. 754 return false; 755 } 756 757 namespace { 758 // Reduce the list of Named Metadata nodes. We keep this as a list of 759 // names to avoid having to convert back and forth every time. 760 class ReduceCrashingNamedMD : public ListReducer<std::string> { 761 BugDriver &BD; 762 bool (*TestFn)(const BugDriver &, Module *); 763 764 public: 765 ReduceCrashingNamedMD(BugDriver &bd, 766 bool (*testFn)(const BugDriver &, Module *)) 767 : BD(bd), TestFn(testFn) {} 768 769 Expected<TestResult> doTest(std::vector<std::string> &Prefix, 770 std::vector<std::string> &Kept) override { 771 if (!Kept.empty() && TestNamedMDs(Kept)) 772 return KeepSuffix; 773 if (!Prefix.empty() && TestNamedMDs(Prefix)) 774 return KeepPrefix; 775 return NoFailure; 776 } 777 778 bool TestNamedMDs(std::vector<std::string> &NamedMDs); 779 }; 780 } 781 782 bool ReduceCrashingNamedMD::TestNamedMDs(std::vector<std::string> &NamedMDs) { 783 784 ValueToValueMapTy VMap; 785 Module *M = CloneModule(BD.getProgram(), VMap).release(); 786 787 outs() << "Checking for crash with only these named metadata nodes:"; 788 unsigned NumPrint = std::min<size_t>(NamedMDs.size(), 10); 789 for (unsigned i = 0, e = NumPrint; i != e; ++i) 790 outs() << " " << NamedMDs[i]; 791 if (NumPrint < NamedMDs.size()) 792 outs() << "... <" << NamedMDs.size() << " total>"; 793 outs() << ": "; 794 795 // Make a StringMap for faster lookup 796 StringSet<> Names; 797 for (const std::string &Name : NamedMDs) 798 Names.insert(Name); 799 800 // First collect all the metadata to delete in a vector, then 801 // delete them all at once to avoid invalidating the iterator 802 std::vector<NamedMDNode *> ToDelete; 803 ToDelete.reserve(M->named_metadata_size() - Names.size()); 804 for (auto &NamedMD : M->named_metadata()) 805 // Always keep a nonempty llvm.dbg.cu because the Verifier would complain. 806 if (!Names.count(NamedMD.getName()) && 807 (!(NamedMD.getName() == "llvm.dbg.cu" && NamedMD.getNumOperands() > 0))) 808 ToDelete.push_back(&NamedMD); 809 810 for (auto *NamedMD : ToDelete) 811 NamedMD->eraseFromParent(); 812 813 // Verify that this is still valid. 814 legacy::PassManager Passes; 815 Passes.add(createVerifierPass()); 816 Passes.run(*M); 817 818 // Try running on the hacked up program... 819 if (TestFn(BD, M)) { 820 BD.setNewProgram(M); // It crashed, keep the trimmed version... 821 return true; 822 } 823 delete M; // It didn't crash, try something else. 824 return false; 825 } 826 827 namespace { 828 // Reduce the list of operands to named metadata nodes 829 class ReduceCrashingNamedMDOps : public ListReducer<const MDNode *> { 830 BugDriver &BD; 831 bool (*TestFn)(const BugDriver &, Module *); 832 833 public: 834 ReduceCrashingNamedMDOps(BugDriver &bd, 835 bool (*testFn)(const BugDriver &, Module *)) 836 : BD(bd), TestFn(testFn) {} 837 838 Expected<TestResult> doTest(std::vector<const MDNode *> &Prefix, 839 std::vector<const MDNode *> &Kept) override { 840 if (!Kept.empty() && TestNamedMDOps(Kept)) 841 return KeepSuffix; 842 if (!Prefix.empty() && TestNamedMDOps(Prefix)) 843 return KeepPrefix; 844 return NoFailure; 845 } 846 847 bool TestNamedMDOps(std::vector<const MDNode *> &NamedMDOps); 848 }; 849 } 850 851 bool ReduceCrashingNamedMDOps::TestNamedMDOps( 852 std::vector<const MDNode *> &NamedMDOps) { 853 // Convert list to set for fast lookup... 854 SmallPtrSet<const MDNode *, 32> OldMDNodeOps; 855 for (unsigned i = 0, e = NamedMDOps.size(); i != e; ++i) { 856 OldMDNodeOps.insert(NamedMDOps[i]); 857 } 858 859 outs() << "Checking for crash with only " << OldMDNodeOps.size(); 860 if (OldMDNodeOps.size() == 1) 861 outs() << " named metadata operand: "; 862 else 863 outs() << " named metadata operands: "; 864 865 ValueToValueMapTy VMap; 866 Module *M = CloneModule(BD.getProgram(), VMap).release(); 867 868 // This is a little wasteful. In the future it might be good if we could have 869 // these dropped during cloning. 870 for (auto &NamedMD : BD.getProgram()->named_metadata()) { 871 // Drop the old one and create a new one 872 M->eraseNamedMetadata(M->getNamedMetadata(NamedMD.getName())); 873 NamedMDNode *NewNamedMDNode = 874 M->getOrInsertNamedMetadata(NamedMD.getName()); 875 for (MDNode *op : NamedMD.operands()) 876 if (OldMDNodeOps.count(op)) 877 NewNamedMDNode->addOperand(cast<MDNode>(MapMetadata(op, VMap))); 878 } 879 880 // Verify that this is still valid. 881 legacy::PassManager Passes; 882 Passes.add(createVerifierPass()); 883 Passes.run(*M); 884 885 // Try running on the hacked up program... 886 if (TestFn(BD, M)) { 887 // Make sure to use instruction pointers that point into the now-current 888 // module, and that they don't include any deleted blocks. 889 NamedMDOps.clear(); 890 for (const MDNode *Node : OldMDNodeOps) 891 NamedMDOps.push_back(cast<MDNode>(*VMap.getMappedMD(Node))); 892 893 BD.setNewProgram(M); // It crashed, keep the trimmed version... 894 return true; 895 } 896 delete M; // It didn't crash, try something else. 897 return false; 898 } 899 900 static Error ReduceGlobalInitializers(BugDriver &BD, 901 bool (*TestFn)(const BugDriver &, 902 Module *)) { 903 if (BD.getProgram()->global_begin() != BD.getProgram()->global_end()) { 904 // Now try to reduce the number of global variable initializers in the 905 // module to something small. 906 Module *M = CloneModule(BD.getProgram()).release(); 907 bool DeletedInit = false; 908 909 for (Module::global_iterator I = M->global_begin(), E = M->global_end(); 910 I != E; ++I) 911 if (I->hasInitializer()) { 912 DeleteGlobalInitializer(&*I); 913 I->setLinkage(GlobalValue::ExternalLinkage); 914 I->setComdat(nullptr); 915 DeletedInit = true; 916 } 917 918 if (!DeletedInit) { 919 delete M; // No change made... 920 } else { 921 // See if the program still causes a crash... 922 outs() << "\nChecking to see if we can delete global inits: "; 923 924 if (TestFn(BD, M)) { // Still crashes? 925 BD.setNewProgram(M); 926 outs() << "\n*** Able to remove all global initializers!\n"; 927 } else { // No longer crashes? 928 outs() << " - Removing all global inits hides problem!\n"; 929 delete M; 930 931 std::vector<GlobalVariable *> GVs; 932 933 for (Module::global_iterator I = BD.getProgram()->global_begin(), 934 E = BD.getProgram()->global_end(); 935 I != E; ++I) 936 if (I->hasInitializer()) 937 GVs.push_back(&*I); 938 939 if (GVs.size() > 1 && !BugpointIsInterrupted) { 940 outs() << "\n*** Attempting to reduce the number of global " 941 << "variables in the testcase\n"; 942 943 unsigned OldSize = GVs.size(); 944 Expected<bool> Result = 945 ReduceCrashingGlobalVariables(BD, TestFn).reduceList(GVs); 946 if (Error E = Result.takeError()) 947 return E; 948 949 if (GVs.size() < OldSize) 950 BD.EmitProgressBitcode(BD.getProgram(), "reduced-global-variables"); 951 } 952 } 953 } 954 } 955 return Error::success(); 956 } 957 958 static Error ReduceInsts(BugDriver &BD, 959 bool (*TestFn)(const BugDriver &, Module *)) { 960 // Attempt to delete instructions using bisection. This should help out nasty 961 // cases with large basic blocks where the problem is at one end. 962 if (!BugpointIsInterrupted) { 963 std::vector<const Instruction *> Insts; 964 for (const Function &F : *BD.getProgram()) 965 for (const BasicBlock &BB : F) 966 for (const Instruction &I : BB) 967 if (!isa<TerminatorInst>(&I)) 968 Insts.push_back(&I); 969 970 Expected<bool> Result = 971 ReduceCrashingInstructions(BD, TestFn).reduceList(Insts); 972 if (Error E = Result.takeError()) 973 return E; 974 } 975 976 unsigned Simplification = 2; 977 do { 978 if (BugpointIsInterrupted) 979 // TODO: Should we distinguish this with an "interrupted error"? 980 return Error::success(); 981 --Simplification; 982 outs() << "\n*** Attempting to reduce testcase by deleting instruc" 983 << "tions: Simplification Level #" << Simplification << '\n'; 984 985 // Now that we have deleted the functions that are unnecessary for the 986 // program, try to remove instructions that are not necessary to cause the 987 // crash. To do this, we loop through all of the instructions in the 988 // remaining functions, deleting them (replacing any values produced with 989 // nulls), and then running ADCE and SimplifyCFG. If the transformed input 990 // still triggers failure, keep deleting until we cannot trigger failure 991 // anymore. 992 // 993 unsigned InstructionsToSkipBeforeDeleting = 0; 994 TryAgain: 995 996 // Loop over all of the (non-terminator) instructions remaining in the 997 // function, attempting to delete them. 998 unsigned CurInstructionNum = 0; 999 for (Module::const_iterator FI = BD.getProgram()->begin(), 1000 E = BD.getProgram()->end(); 1001 FI != E; ++FI) 1002 if (!FI->isDeclaration()) 1003 for (Function::const_iterator BI = FI->begin(), E = FI->end(); BI != E; 1004 ++BI) 1005 for (BasicBlock::const_iterator I = BI->begin(), E = --BI->end(); 1006 I != E; ++I, ++CurInstructionNum) { 1007 if (InstructionsToSkipBeforeDeleting) { 1008 --InstructionsToSkipBeforeDeleting; 1009 } else { 1010 if (BugpointIsInterrupted) 1011 // TODO: Should this be some kind of interrupted error? 1012 return Error::success(); 1013 1014 if (I->isEHPad() || I->getType()->isTokenTy()) 1015 continue; 1016 1017 outs() << "Checking instruction: " << *I; 1018 std::unique_ptr<Module> M = 1019 BD.deleteInstructionFromProgram(&*I, Simplification); 1020 1021 // Find out if the pass still crashes on this pass... 1022 if (TestFn(BD, M.get())) { 1023 // Yup, it does, we delete the old module, and continue trying 1024 // to reduce the testcase... 1025 BD.setNewProgram(M.release()); 1026 InstructionsToSkipBeforeDeleting = CurInstructionNum; 1027 goto TryAgain; // I wish I had a multi-level break here! 1028 } 1029 } 1030 } 1031 1032 if (InstructionsToSkipBeforeDeleting) { 1033 InstructionsToSkipBeforeDeleting = 0; 1034 goto TryAgain; 1035 } 1036 1037 } while (Simplification); 1038 BD.EmitProgressBitcode(BD.getProgram(), "reduced-instructions"); 1039 return Error::success(); 1040 } 1041 1042 /// DebugACrash - Given a predicate that determines whether a component crashes 1043 /// on a program, try to destructively reduce the program while still keeping 1044 /// the predicate true. 1045 static Error DebugACrash(BugDriver &BD, 1046 bool (*TestFn)(const BugDriver &, Module *)) { 1047 // See if we can get away with nuking some of the global variable initializers 1048 // in the program... 1049 if (!NoGlobalRM) 1050 if (Error E = ReduceGlobalInitializers(BD, TestFn)) 1051 return E; 1052 1053 // Now try to reduce the number of functions in the module to something small. 1054 std::vector<Function *> Functions; 1055 for (Function &F : *BD.getProgram()) 1056 if (!F.isDeclaration()) 1057 Functions.push_back(&F); 1058 1059 if (Functions.size() > 1 && !BugpointIsInterrupted) { 1060 outs() << "\n*** Attempting to reduce the number of functions " 1061 "in the testcase\n"; 1062 1063 unsigned OldSize = Functions.size(); 1064 Expected<bool> Result = 1065 ReduceCrashingFunctions(BD, TestFn).reduceList(Functions); 1066 if (Error E = Result.takeError()) 1067 return E; 1068 1069 if (Functions.size() < OldSize) 1070 BD.EmitProgressBitcode(BD.getProgram(), "reduced-function"); 1071 } 1072 1073 // Attempt to change conditional branches into unconditional branches to 1074 // eliminate blocks. 1075 if (!DisableSimplifyCFG && !BugpointIsInterrupted) { 1076 std::vector<const BasicBlock *> Blocks; 1077 for (Function &F : *BD.getProgram()) 1078 for (BasicBlock &BB : F) 1079 Blocks.push_back(&BB); 1080 unsigned OldSize = Blocks.size(); 1081 Expected<bool> Result = 1082 ReduceCrashingConditionals(BD, TestFn, true).reduceList(Blocks); 1083 if (Error E = Result.takeError()) 1084 return E; 1085 Result = ReduceCrashingConditionals(BD, TestFn, false).reduceList(Blocks); 1086 if (Error E = Result.takeError()) 1087 return E; 1088 if (Blocks.size() < OldSize) 1089 BD.EmitProgressBitcode(BD.getProgram(), "reduced-conditionals"); 1090 } 1091 1092 // Attempt to delete entire basic blocks at a time to speed up 1093 // convergence... this actually works by setting the terminator of the blocks 1094 // to a return instruction then running simplifycfg, which can potentially 1095 // shrinks the code dramatically quickly 1096 // 1097 if (!DisableSimplifyCFG && !BugpointIsInterrupted) { 1098 std::vector<const BasicBlock *> Blocks; 1099 for (Function &F : *BD.getProgram()) 1100 for (BasicBlock &BB : F) 1101 Blocks.push_back(&BB); 1102 unsigned OldSize = Blocks.size(); 1103 Expected<bool> Result = ReduceCrashingBlocks(BD, TestFn).reduceList(Blocks); 1104 if (Error E = Result.takeError()) 1105 return E; 1106 if (Blocks.size() < OldSize) 1107 BD.EmitProgressBitcode(BD.getProgram(), "reduced-blocks"); 1108 } 1109 1110 if (!DisableSimplifyCFG & !BugpointIsInterrupted) { 1111 std::vector<const BasicBlock *> Blocks; 1112 for (Function &F : *BD.getProgram()) 1113 for (BasicBlock &BB : F) 1114 Blocks.push_back(&BB); 1115 unsigned OldSize = Blocks.size(); 1116 Expected<bool> Result = ReduceSimplifyCFG(BD, TestFn).reduceList(Blocks); 1117 if (Error E = Result.takeError()) 1118 return E; 1119 if (Blocks.size() < OldSize) 1120 BD.EmitProgressBitcode(BD.getProgram(), "reduced-simplifycfg"); 1121 } 1122 1123 // Attempt to delete instructions using bisection. This should help out nasty 1124 // cases with large basic blocks where the problem is at one end. 1125 if (!BugpointIsInterrupted) 1126 if (Error E = ReduceInsts(BD, TestFn)) 1127 return E; 1128 1129 if (!NoNamedMDRM) { 1130 if (!BugpointIsInterrupted) { 1131 // Try to reduce the amount of global metadata (particularly debug info), 1132 // by dropping global named metadata that anchors them 1133 outs() << "\n*** Attempting to remove named metadata: "; 1134 std::vector<std::string> NamedMDNames; 1135 for (auto &NamedMD : BD.getProgram()->named_metadata()) 1136 NamedMDNames.push_back(NamedMD.getName().str()); 1137 Expected<bool> Result = 1138 ReduceCrashingNamedMD(BD, TestFn).reduceList(NamedMDNames); 1139 if (Error E = Result.takeError()) 1140 return E; 1141 } 1142 1143 if (!BugpointIsInterrupted) { 1144 // Now that we quickly dropped all the named metadata that doesn't 1145 // contribute to the crash, bisect the operands of the remaining ones 1146 std::vector<const MDNode *> NamedMDOps; 1147 for (auto &NamedMD : BD.getProgram()->named_metadata()) 1148 for (auto op : NamedMD.operands()) 1149 NamedMDOps.push_back(op); 1150 Expected<bool> Result = 1151 ReduceCrashingNamedMDOps(BD, TestFn).reduceList(NamedMDOps); 1152 if (Error E = Result.takeError()) 1153 return E; 1154 } 1155 BD.EmitProgressBitcode(BD.getProgram(), "reduced-named-md"); 1156 } 1157 1158 // Try to clean up the testcase by running funcresolve and globaldce... 1159 if (!BugpointIsInterrupted) { 1160 outs() << "\n*** Attempting to perform final cleanups: "; 1161 Module *M = CloneModule(BD.getProgram()).release(); 1162 M = BD.performFinalCleanups(M, true).release(); 1163 1164 // Find out if the pass still crashes on the cleaned up program... 1165 if (TestFn(BD, M)) { 1166 BD.setNewProgram(M); // Yup, it does, keep the reduced version... 1167 } else { 1168 delete M; 1169 } 1170 } 1171 1172 BD.EmitProgressBitcode(BD.getProgram(), "reduced-simplified"); 1173 1174 return Error::success(); 1175 } 1176 1177 static bool TestForOptimizerCrash(const BugDriver &BD, Module *M) { 1178 return BD.runPasses(M, BD.getPassesToRun()); 1179 } 1180 1181 /// debugOptimizerCrash - This method is called when some pass crashes on input. 1182 /// It attempts to prune down the testcase to something reasonable, and figure 1183 /// out exactly which pass is crashing. 1184 /// 1185 Error BugDriver::debugOptimizerCrash(const std::string &ID) { 1186 outs() << "\n*** Debugging optimizer crash!\n"; 1187 1188 // Reduce the list of passes which causes the optimizer to crash... 1189 if (!BugpointIsInterrupted && !DontReducePassList) { 1190 Expected<bool> Result = ReducePassList(*this).reduceList(PassesToRun); 1191 if (Error E = Result.takeError()) 1192 return E; 1193 } 1194 1195 outs() << "\n*** Found crashing pass" 1196 << (PassesToRun.size() == 1 ? ": " : "es: ") 1197 << getPassesString(PassesToRun) << '\n'; 1198 1199 EmitProgressBitcode(Program, ID); 1200 1201 return DebugACrash(*this, TestForOptimizerCrash); 1202 } 1203 1204 static bool TestForCodeGenCrash(const BugDriver &BD, Module *M) { 1205 if (Error E = BD.compileProgram(M)) { 1206 if (VerboseErrors) 1207 errs() << toString(std::move(E)) << "\n"; 1208 else { 1209 consumeError(std::move(E)); 1210 errs() << "<crash>\n"; 1211 } 1212 return true; // Tool is still crashing. 1213 } 1214 errs() << '\n'; 1215 return false; 1216 } 1217 1218 /// debugCodeGeneratorCrash - This method is called when the code generator 1219 /// crashes on an input. It attempts to reduce the input as much as possible 1220 /// while still causing the code generator to crash. 1221 Error BugDriver::debugCodeGeneratorCrash() { 1222 errs() << "*** Debugging code generator crash!\n"; 1223 1224 return DebugACrash(*this, TestForCodeGenCrash); 1225 } 1226