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 Value *V = F->getValueSymbolTable()->lookup(BlockInfo[i].second); 465 if (V && V->getType() == Type::getLabelTy(V->getContext())) 466 BBs.push_back(cast<BasicBlock>(V)); 467 } 468 return true; 469 } 470 delete M; // It didn't crash, try something else. 471 return false; 472 } 473 474 namespace { 475 /// ReduceCrashingConditionals reducer - This works by changing 476 /// conditional branches to unconditional ones, then simplifying the CFG 477 /// This has the effect of chopping up the CFG really fast which can reduce 478 /// large functions quickly. 479 /// 480 class ReduceCrashingConditionals : public ListReducer<const BasicBlock *> { 481 BugDriver &BD; 482 bool (*TestFn)(const BugDriver &, Module *); 483 bool Direction; 484 485 public: 486 ReduceCrashingConditionals(BugDriver &bd, 487 bool (*testFn)(const BugDriver &, Module *), 488 bool Direction) 489 : BD(bd), TestFn(testFn), Direction(Direction) {} 490 491 Expected<TestResult> doTest(std::vector<const BasicBlock *> &Prefix, 492 std::vector<const BasicBlock *> &Kept) override { 493 if (!Kept.empty() && TestBlocks(Kept)) 494 return KeepSuffix; 495 if (!Prefix.empty() && TestBlocks(Prefix)) 496 return KeepPrefix; 497 return NoFailure; 498 } 499 500 bool TestBlocks(std::vector<const BasicBlock *> &Prefix); 501 }; 502 } 503 504 bool ReduceCrashingConditionals::TestBlocks( 505 std::vector<const BasicBlock *> &BBs) { 506 // Clone the program to try hacking it apart... 507 ValueToValueMapTy VMap; 508 Module *M = CloneModule(BD.getProgram(), VMap).release(); 509 510 // Convert list to set for fast lookup... 511 SmallPtrSet<const BasicBlock *, 8> Blocks; 512 for (const auto *BB : BBs) 513 Blocks.insert(cast<BasicBlock>(VMap[BB])); 514 515 outs() << "Checking for crash with changing conditionals to always jump to " 516 << (Direction ? "true" : "false") << ":"; 517 unsigned NumPrint = Blocks.size(); 518 if (NumPrint > 10) 519 NumPrint = 10; 520 for (unsigned i = 0, e = NumPrint; i != e; ++i) 521 outs() << " " << BBs[i]->getName(); 522 if (NumPrint < Blocks.size()) 523 outs() << "... <" << Blocks.size() << " total>"; 524 outs() << ": "; 525 526 // Loop over and delete any hack up any blocks that are not listed... 527 for (auto &F : *M) 528 for (auto &BB : F) 529 if (!Blocks.count(&BB)) { 530 auto *BR = dyn_cast<BranchInst>(BB.getTerminator()); 531 if (!BR || !BR->isConditional()) 532 continue; 533 if (Direction) 534 BR->setCondition(ConstantInt::getTrue(BR->getContext())); 535 else 536 BR->setCondition(ConstantInt::getFalse(BR->getContext())); 537 } 538 539 // The following may destroy some blocks, so we save them first 540 std::vector<std::pair<std::string, std::string>> BlockInfo; 541 542 for (const BasicBlock *BB : Blocks) 543 BlockInfo.emplace_back(BB->getParent()->getName(), BB->getName()); 544 545 SmallVector<BasicBlock *, 16> ToProcess; 546 for (auto &F : *M) { 547 for (auto &BB : F) 548 if (!Blocks.count(&BB)) 549 ToProcess.push_back(&BB); 550 simpleSimplifyCfg(F, ToProcess); 551 ToProcess.clear(); 552 } 553 // Verify we didn't break anything 554 std::vector<std::string> Passes; 555 Passes.push_back("verify"); 556 std::unique_ptr<Module> New = BD.runPassesOn(M, Passes); 557 delete M; 558 if (!New) { 559 errs() << "verify failed!\n"; 560 exit(1); 561 } 562 M = New.release(); 563 564 // Try running on the hacked up program... 565 if (TestFn(BD, M)) { 566 BD.setNewProgram(M); // It crashed, keep the trimmed version... 567 568 // Make sure to use basic block pointers that point into the now-current 569 // module, and that they don't include any deleted blocks. 570 BBs.clear(); 571 const ValueSymbolTable &GST = M->getValueSymbolTable(); 572 for (auto &BI : BlockInfo) { 573 auto *F = cast<Function>(GST.lookup(BI.first)); 574 Value *V = F->getValueSymbolTable()->lookup(BI.second); 575 if (V && V->getType() == Type::getLabelTy(V->getContext())) 576 BBs.push_back(cast<BasicBlock>(V)); 577 } 578 return true; 579 } 580 delete M; // It didn't crash, try something else. 581 return false; 582 } 583 584 namespace { 585 /// SimplifyCFG reducer - This works by calling SimplifyCFG on each basic block 586 /// in the program. 587 588 class ReduceSimplifyCFG : public ListReducer<const BasicBlock *> { 589 BugDriver &BD; 590 bool (*TestFn)(const BugDriver &, Module *); 591 TargetTransformInfo TTI; 592 593 public: 594 ReduceSimplifyCFG(BugDriver &bd, bool (*testFn)(const BugDriver &, Module *)) 595 : BD(bd), TestFn(testFn), TTI(bd.getProgram()->getDataLayout()) {} 596 597 Expected<TestResult> doTest(std::vector<const BasicBlock *> &Prefix, 598 std::vector<const BasicBlock *> &Kept) override { 599 if (!Kept.empty() && TestBlocks(Kept)) 600 return KeepSuffix; 601 if (!Prefix.empty() && TestBlocks(Prefix)) 602 return KeepPrefix; 603 return NoFailure; 604 } 605 606 bool TestBlocks(std::vector<const BasicBlock *> &Prefix); 607 }; 608 } 609 610 bool ReduceSimplifyCFG::TestBlocks(std::vector<const BasicBlock *> &BBs) { 611 // Clone the program to try hacking it apart... 612 ValueToValueMapTy VMap; 613 Module *M = CloneModule(BD.getProgram(), VMap).release(); 614 615 // Convert list to set for fast lookup... 616 SmallPtrSet<const BasicBlock *, 8> Blocks; 617 for (const auto *BB : BBs) 618 Blocks.insert(cast<BasicBlock>(VMap[BB])); 619 620 outs() << "Checking for crash with CFG simplifying:"; 621 unsigned NumPrint = Blocks.size(); 622 if (NumPrint > 10) 623 NumPrint = 10; 624 for (unsigned i = 0, e = NumPrint; i != e; ++i) 625 outs() << " " << BBs[i]->getName(); 626 if (NumPrint < Blocks.size()) 627 outs() << "... <" << Blocks.size() << " total>"; 628 outs() << ": "; 629 630 // The following may destroy some blocks, so we save them first 631 std::vector<std::pair<std::string, std::string>> BlockInfo; 632 633 for (const BasicBlock *BB : Blocks) 634 BlockInfo.emplace_back(BB->getParent()->getName(), BB->getName()); 635 636 // Loop over and delete any hack up any blocks that are not listed... 637 for (auto &F : *M) 638 // Loop over all of the basic blocks and remove them if they are unneeded. 639 for (Function::iterator BBIt = F.begin(); BBIt != F.end();) { 640 if (!Blocks.count(&*BBIt)) { 641 ++BBIt; 642 continue; 643 } 644 SimplifyCFG(&*BBIt++, TTI, 1); 645 } 646 // Verify we didn't break anything 647 std::vector<std::string> Passes; 648 Passes.push_back("verify"); 649 std::unique_ptr<Module> New = BD.runPassesOn(M, Passes); 650 delete M; 651 if (!New) { 652 errs() << "verify failed!\n"; 653 exit(1); 654 } 655 M = New.release(); 656 657 // Try running on the hacked up program... 658 if (TestFn(BD, M)) { 659 BD.setNewProgram(M); // It crashed, keep the trimmed version... 660 661 // Make sure to use basic block pointers that point into the now-current 662 // module, and that they don't include any deleted blocks. 663 BBs.clear(); 664 const ValueSymbolTable &GST = M->getValueSymbolTable(); 665 for (auto &BI : BlockInfo) { 666 auto *F = cast<Function>(GST.lookup(BI.first)); 667 Value *V = F->getValueSymbolTable()->lookup(BI.second); 668 if (V && V->getType() == Type::getLabelTy(V->getContext())) 669 BBs.push_back(cast<BasicBlock>(V)); 670 } 671 return true; 672 } 673 delete M; // It didn't crash, try something else. 674 return false; 675 } 676 677 namespace { 678 /// ReduceCrashingInstructions reducer - This works by removing the specified 679 /// non-terminator instructions and replacing them with undef. 680 /// 681 class ReduceCrashingInstructions : public ListReducer<const Instruction *> { 682 BugDriver &BD; 683 bool (*TestFn)(const BugDriver &, Module *); 684 685 public: 686 ReduceCrashingInstructions(BugDriver &bd, 687 bool (*testFn)(const BugDriver &, Module *)) 688 : BD(bd), TestFn(testFn) {} 689 690 Expected<TestResult> doTest(std::vector<const Instruction *> &Prefix, 691 std::vector<const Instruction *> &Kept) override { 692 if (!Kept.empty() && TestInsts(Kept)) 693 return KeepSuffix; 694 if (!Prefix.empty() && TestInsts(Prefix)) 695 return KeepPrefix; 696 return NoFailure; 697 } 698 699 bool TestInsts(std::vector<const Instruction *> &Prefix); 700 }; 701 } 702 703 bool ReduceCrashingInstructions::TestInsts( 704 std::vector<const Instruction *> &Insts) { 705 // Clone the program to try hacking it apart... 706 ValueToValueMapTy VMap; 707 Module *M = CloneModule(BD.getProgram(), VMap).release(); 708 709 // Convert list to set for fast lookup... 710 SmallPtrSet<Instruction *, 32> Instructions; 711 for (unsigned i = 0, e = Insts.size(); i != e; ++i) { 712 assert(!isa<TerminatorInst>(Insts[i])); 713 Instructions.insert(cast<Instruction>(VMap[Insts[i]])); 714 } 715 716 outs() << "Checking for crash with only " << Instructions.size(); 717 if (Instructions.size() == 1) 718 outs() << " instruction: "; 719 else 720 outs() << " instructions: "; 721 722 for (Module::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) 723 for (Function::iterator FI = MI->begin(), FE = MI->end(); FI != FE; ++FI) 724 for (BasicBlock::iterator I = FI->begin(), E = FI->end(); I != E;) { 725 Instruction *Inst = &*I++; 726 if (!Instructions.count(Inst) && !isa<TerminatorInst>(Inst) && 727 !Inst->isEHPad() && !Inst->getType()->isTokenTy()) { 728 if (!Inst->getType()->isVoidTy()) 729 Inst->replaceAllUsesWith(UndefValue::get(Inst->getType())); 730 Inst->eraseFromParent(); 731 } 732 } 733 734 // Verify that this is still valid. 735 legacy::PassManager Passes; 736 Passes.add(createVerifierPass()); 737 Passes.run(*M); 738 739 // Try running on the hacked up program... 740 if (TestFn(BD, M)) { 741 BD.setNewProgram(M); // It crashed, keep the trimmed version... 742 743 // Make sure to use instruction pointers that point into the now-current 744 // module, and that they don't include any deleted blocks. 745 Insts.clear(); 746 for (Instruction *Inst : Instructions) 747 Insts.push_back(Inst); 748 return true; 749 } 750 delete M; // It didn't crash, try something else. 751 return false; 752 } 753 754 namespace { 755 // Reduce the list of Named Metadata nodes. We keep this as a list of 756 // names to avoid having to convert back and forth every time. 757 class ReduceCrashingNamedMD : public ListReducer<std::string> { 758 BugDriver &BD; 759 bool (*TestFn)(const BugDriver &, Module *); 760 761 public: 762 ReduceCrashingNamedMD(BugDriver &bd, 763 bool (*testFn)(const BugDriver &, Module *)) 764 : BD(bd), TestFn(testFn) {} 765 766 Expected<TestResult> doTest(std::vector<std::string> &Prefix, 767 std::vector<std::string> &Kept) override { 768 if (!Kept.empty() && TestNamedMDs(Kept)) 769 return KeepSuffix; 770 if (!Prefix.empty() && TestNamedMDs(Prefix)) 771 return KeepPrefix; 772 return NoFailure; 773 } 774 775 bool TestNamedMDs(std::vector<std::string> &NamedMDs); 776 }; 777 } 778 779 bool ReduceCrashingNamedMD::TestNamedMDs(std::vector<std::string> &NamedMDs) { 780 781 ValueToValueMapTy VMap; 782 Module *M = CloneModule(BD.getProgram(), VMap).release(); 783 784 outs() << "Checking for crash with only these named metadata nodes:"; 785 unsigned NumPrint = std::min<size_t>(NamedMDs.size(), 10); 786 for (unsigned i = 0, e = NumPrint; i != e; ++i) 787 outs() << " " << NamedMDs[i]; 788 if (NumPrint < NamedMDs.size()) 789 outs() << "... <" << NamedMDs.size() << " total>"; 790 outs() << ": "; 791 792 // Make a StringMap for faster lookup 793 StringSet<> Names; 794 for (const std::string &Name : NamedMDs) 795 Names.insert(Name); 796 797 // First collect all the metadata to delete in a vector, then 798 // delete them all at once to avoid invalidating the iterator 799 std::vector<NamedMDNode *> ToDelete; 800 ToDelete.reserve(M->named_metadata_size() - Names.size()); 801 for (auto &NamedMD : M->named_metadata()) 802 // Always keep a nonempty llvm.dbg.cu because the Verifier would complain. 803 if (!Names.count(NamedMD.getName()) && 804 (!(NamedMD.getName() == "llvm.dbg.cu" && NamedMD.getNumOperands() > 0))) 805 ToDelete.push_back(&NamedMD); 806 807 for (auto *NamedMD : ToDelete) 808 NamedMD->eraseFromParent(); 809 810 // Verify that this is still valid. 811 legacy::PassManager Passes; 812 Passes.add(createVerifierPass()); 813 Passes.run(*M); 814 815 // Try running on the hacked up program... 816 if (TestFn(BD, M)) { 817 BD.setNewProgram(M); // It crashed, keep the trimmed version... 818 return true; 819 } 820 delete M; // It didn't crash, try something else. 821 return false; 822 } 823 824 namespace { 825 // Reduce the list of operands to named metadata nodes 826 class ReduceCrashingNamedMDOps : public ListReducer<const MDNode *> { 827 BugDriver &BD; 828 bool (*TestFn)(const BugDriver &, Module *); 829 830 public: 831 ReduceCrashingNamedMDOps(BugDriver &bd, 832 bool (*testFn)(const BugDriver &, Module *)) 833 : BD(bd), TestFn(testFn) {} 834 835 Expected<TestResult> doTest(std::vector<const MDNode *> &Prefix, 836 std::vector<const MDNode *> &Kept) override { 837 if (!Kept.empty() && TestNamedMDOps(Kept)) 838 return KeepSuffix; 839 if (!Prefix.empty() && TestNamedMDOps(Prefix)) 840 return KeepPrefix; 841 return NoFailure; 842 } 843 844 bool TestNamedMDOps(std::vector<const MDNode *> &NamedMDOps); 845 }; 846 } 847 848 bool ReduceCrashingNamedMDOps::TestNamedMDOps( 849 std::vector<const MDNode *> &NamedMDOps) { 850 // Convert list to set for fast lookup... 851 SmallPtrSet<const MDNode *, 32> OldMDNodeOps; 852 for (unsigned i = 0, e = NamedMDOps.size(); i != e; ++i) { 853 OldMDNodeOps.insert(NamedMDOps[i]); 854 } 855 856 outs() << "Checking for crash with only " << OldMDNodeOps.size(); 857 if (OldMDNodeOps.size() == 1) 858 outs() << " named metadata operand: "; 859 else 860 outs() << " named metadata operands: "; 861 862 ValueToValueMapTy VMap; 863 Module *M = CloneModule(BD.getProgram(), VMap).release(); 864 865 // This is a little wasteful. In the future it might be good if we could have 866 // these dropped during cloning. 867 for (auto &NamedMD : BD.getProgram()->named_metadata()) { 868 // Drop the old one and create a new one 869 M->eraseNamedMetadata(M->getNamedMetadata(NamedMD.getName())); 870 NamedMDNode *NewNamedMDNode = 871 M->getOrInsertNamedMetadata(NamedMD.getName()); 872 for (MDNode *op : NamedMD.operands()) 873 if (OldMDNodeOps.count(op)) 874 NewNamedMDNode->addOperand(cast<MDNode>(MapMetadata(op, VMap))); 875 } 876 877 // Verify that this is still valid. 878 legacy::PassManager Passes; 879 Passes.add(createVerifierPass()); 880 Passes.run(*M); 881 882 // Try running on the hacked up program... 883 if (TestFn(BD, M)) { 884 // Make sure to use instruction pointers that point into the now-current 885 // module, and that they don't include any deleted blocks. 886 NamedMDOps.clear(); 887 for (const MDNode *Node : OldMDNodeOps) 888 NamedMDOps.push_back(cast<MDNode>(*VMap.getMappedMD(Node))); 889 890 BD.setNewProgram(M); // It crashed, keep the trimmed version... 891 return true; 892 } 893 delete M; // It didn't crash, try something else. 894 return false; 895 } 896 897 static Error ReduceGlobalInitializers(BugDriver &BD, 898 bool (*TestFn)(const BugDriver &, 899 Module *)) { 900 if (BD.getProgram()->global_begin() != BD.getProgram()->global_end()) { 901 // Now try to reduce the number of global variable initializers in the 902 // module to something small. 903 Module *M = CloneModule(BD.getProgram()).release(); 904 bool DeletedInit = false; 905 906 for (Module::global_iterator I = M->global_begin(), E = M->global_end(); 907 I != E; ++I) 908 if (I->hasInitializer()) { 909 DeleteGlobalInitializer(&*I); 910 I->setLinkage(GlobalValue::ExternalLinkage); 911 I->setComdat(nullptr); 912 DeletedInit = true; 913 } 914 915 if (!DeletedInit) { 916 delete M; // No change made... 917 } else { 918 // See if the program still causes a crash... 919 outs() << "\nChecking to see if we can delete global inits: "; 920 921 if (TestFn(BD, M)) { // Still crashes? 922 BD.setNewProgram(M); 923 outs() << "\n*** Able to remove all global initializers!\n"; 924 } else { // No longer crashes? 925 outs() << " - Removing all global inits hides problem!\n"; 926 delete M; 927 928 std::vector<GlobalVariable *> GVs; 929 930 for (Module::global_iterator I = BD.getProgram()->global_begin(), 931 E = BD.getProgram()->global_end(); 932 I != E; ++I) 933 if (I->hasInitializer()) 934 GVs.push_back(&*I); 935 936 if (GVs.size() > 1 && !BugpointIsInterrupted) { 937 outs() << "\n*** Attempting to reduce the number of global " 938 << "variables in the testcase\n"; 939 940 unsigned OldSize = GVs.size(); 941 Expected<bool> Result = 942 ReduceCrashingGlobalVariables(BD, TestFn).reduceList(GVs); 943 if (Error E = Result.takeError()) 944 return E; 945 946 if (GVs.size() < OldSize) 947 BD.EmitProgressBitcode(BD.getProgram(), "reduced-global-variables"); 948 } 949 } 950 } 951 } 952 return Error::success(); 953 } 954 955 static Error ReduceInsts(BugDriver &BD, 956 bool (*TestFn)(const BugDriver &, Module *)) { 957 // Attempt to delete instructions using bisection. This should help out nasty 958 // cases with large basic blocks where the problem is at one end. 959 if (!BugpointIsInterrupted) { 960 std::vector<const Instruction *> Insts; 961 for (const Function &F : *BD.getProgram()) 962 for (const BasicBlock &BB : F) 963 for (const Instruction &I : BB) 964 if (!isa<TerminatorInst>(&I)) 965 Insts.push_back(&I); 966 967 Expected<bool> Result = 968 ReduceCrashingInstructions(BD, TestFn).reduceList(Insts); 969 if (Error E = Result.takeError()) 970 return E; 971 } 972 973 unsigned Simplification = 2; 974 do { 975 if (BugpointIsInterrupted) 976 // TODO: Should we distinguish this with an "interrupted error"? 977 return Error::success(); 978 --Simplification; 979 outs() << "\n*** Attempting to reduce testcase by deleting instruc" 980 << "tions: Simplification Level #" << Simplification << '\n'; 981 982 // Now that we have deleted the functions that are unnecessary for the 983 // program, try to remove instructions that are not necessary to cause the 984 // crash. To do this, we loop through all of the instructions in the 985 // remaining functions, deleting them (replacing any values produced with 986 // nulls), and then running ADCE and SimplifyCFG. If the transformed input 987 // still triggers failure, keep deleting until we cannot trigger failure 988 // anymore. 989 // 990 unsigned InstructionsToSkipBeforeDeleting = 0; 991 TryAgain: 992 993 // Loop over all of the (non-terminator) instructions remaining in the 994 // function, attempting to delete them. 995 unsigned CurInstructionNum = 0; 996 for (Module::const_iterator FI = BD.getProgram()->begin(), 997 E = BD.getProgram()->end(); 998 FI != E; ++FI) 999 if (!FI->isDeclaration()) 1000 for (Function::const_iterator BI = FI->begin(), E = FI->end(); BI != E; 1001 ++BI) 1002 for (BasicBlock::const_iterator I = BI->begin(), E = --BI->end(); 1003 I != E; ++I, ++CurInstructionNum) { 1004 if (InstructionsToSkipBeforeDeleting) { 1005 --InstructionsToSkipBeforeDeleting; 1006 } else { 1007 if (BugpointIsInterrupted) 1008 // TODO: Should this be some kind of interrupted error? 1009 return Error::success(); 1010 1011 if (I->isEHPad() || I->getType()->isTokenTy()) 1012 continue; 1013 1014 outs() << "Checking instruction: " << *I; 1015 std::unique_ptr<Module> M = 1016 BD.deleteInstructionFromProgram(&*I, Simplification); 1017 1018 // Find out if the pass still crashes on this pass... 1019 if (TestFn(BD, M.get())) { 1020 // Yup, it does, we delete the old module, and continue trying 1021 // to reduce the testcase... 1022 BD.setNewProgram(M.release()); 1023 InstructionsToSkipBeforeDeleting = CurInstructionNum; 1024 goto TryAgain; // I wish I had a multi-level break here! 1025 } 1026 } 1027 } 1028 1029 if (InstructionsToSkipBeforeDeleting) { 1030 InstructionsToSkipBeforeDeleting = 0; 1031 goto TryAgain; 1032 } 1033 1034 } while (Simplification); 1035 BD.EmitProgressBitcode(BD.getProgram(), "reduced-instructions"); 1036 return Error::success(); 1037 } 1038 1039 /// DebugACrash - Given a predicate that determines whether a component crashes 1040 /// on a program, try to destructively reduce the program while still keeping 1041 /// the predicate true. 1042 static Error DebugACrash(BugDriver &BD, 1043 bool (*TestFn)(const BugDriver &, Module *)) { 1044 // See if we can get away with nuking some of the global variable initializers 1045 // in the program... 1046 if (!NoGlobalRM) 1047 if (Error E = ReduceGlobalInitializers(BD, TestFn)) 1048 return E; 1049 1050 // Now try to reduce the number of functions in the module to something small. 1051 std::vector<Function *> Functions; 1052 for (Function &F : *BD.getProgram()) 1053 if (!F.isDeclaration()) 1054 Functions.push_back(&F); 1055 1056 if (Functions.size() > 1 && !BugpointIsInterrupted) { 1057 outs() << "\n*** Attempting to reduce the number of functions " 1058 "in the testcase\n"; 1059 1060 unsigned OldSize = Functions.size(); 1061 Expected<bool> Result = 1062 ReduceCrashingFunctions(BD, TestFn).reduceList(Functions); 1063 if (Error E = Result.takeError()) 1064 return E; 1065 1066 if (Functions.size() < OldSize) 1067 BD.EmitProgressBitcode(BD.getProgram(), "reduced-function"); 1068 } 1069 1070 // Attempt to change conditional branches into unconditional branches to 1071 // eliminate blocks. 1072 if (!DisableSimplifyCFG && !BugpointIsInterrupted) { 1073 std::vector<const BasicBlock *> Blocks; 1074 for (Function &F : *BD.getProgram()) 1075 for (BasicBlock &BB : F) 1076 Blocks.push_back(&BB); 1077 unsigned OldSize = Blocks.size(); 1078 Expected<bool> Result = 1079 ReduceCrashingConditionals(BD, TestFn, true).reduceList(Blocks); 1080 if (Error E = Result.takeError()) 1081 return E; 1082 Result = ReduceCrashingConditionals(BD, TestFn, false).reduceList(Blocks); 1083 if (Error E = Result.takeError()) 1084 return E; 1085 if (Blocks.size() < OldSize) 1086 BD.EmitProgressBitcode(BD.getProgram(), "reduced-conditionals"); 1087 } 1088 1089 // Attempt to delete entire basic blocks at a time to speed up 1090 // convergence... this actually works by setting the terminator of the blocks 1091 // to a return instruction then running simplifycfg, which can potentially 1092 // shrinks the code dramatically quickly 1093 // 1094 if (!DisableSimplifyCFG && !BugpointIsInterrupted) { 1095 std::vector<const BasicBlock *> Blocks; 1096 for (Function &F : *BD.getProgram()) 1097 for (BasicBlock &BB : F) 1098 Blocks.push_back(&BB); 1099 unsigned OldSize = Blocks.size(); 1100 Expected<bool> Result = ReduceCrashingBlocks(BD, TestFn).reduceList(Blocks); 1101 if (Error E = Result.takeError()) 1102 return E; 1103 if (Blocks.size() < OldSize) 1104 BD.EmitProgressBitcode(BD.getProgram(), "reduced-blocks"); 1105 } 1106 1107 if (!DisableSimplifyCFG & !BugpointIsInterrupted) { 1108 std::vector<const BasicBlock *> Blocks; 1109 for (Function &F : *BD.getProgram()) 1110 for (BasicBlock &BB : F) 1111 Blocks.push_back(&BB); 1112 unsigned OldSize = Blocks.size(); 1113 Expected<bool> Result = ReduceSimplifyCFG(BD, TestFn).reduceList(Blocks); 1114 if (Error E = Result.takeError()) 1115 return E; 1116 if (Blocks.size() < OldSize) 1117 BD.EmitProgressBitcode(BD.getProgram(), "reduced-simplifycfg"); 1118 } 1119 1120 // Attempt to delete instructions using bisection. This should help out nasty 1121 // cases with large basic blocks where the problem is at one end. 1122 if (!BugpointIsInterrupted) 1123 if (Error E = ReduceInsts(BD, TestFn)) 1124 return E; 1125 1126 if (!NoNamedMDRM) { 1127 if (!BugpointIsInterrupted) { 1128 // Try to reduce the amount of global metadata (particularly debug info), 1129 // by dropping global named metadata that anchors them 1130 outs() << "\n*** Attempting to remove named metadata: "; 1131 std::vector<std::string> NamedMDNames; 1132 for (auto &NamedMD : BD.getProgram()->named_metadata()) 1133 NamedMDNames.push_back(NamedMD.getName().str()); 1134 Expected<bool> Result = 1135 ReduceCrashingNamedMD(BD, TestFn).reduceList(NamedMDNames); 1136 if (Error E = Result.takeError()) 1137 return E; 1138 } 1139 1140 if (!BugpointIsInterrupted) { 1141 // Now that we quickly dropped all the named metadata that doesn't 1142 // contribute to the crash, bisect the operands of the remaining ones 1143 std::vector<const MDNode *> NamedMDOps; 1144 for (auto &NamedMD : BD.getProgram()->named_metadata()) 1145 for (auto op : NamedMD.operands()) 1146 NamedMDOps.push_back(op); 1147 Expected<bool> Result = 1148 ReduceCrashingNamedMDOps(BD, TestFn).reduceList(NamedMDOps); 1149 if (Error E = Result.takeError()) 1150 return E; 1151 } 1152 BD.EmitProgressBitcode(BD.getProgram(), "reduced-named-md"); 1153 } 1154 1155 // Try to clean up the testcase by running funcresolve and globaldce... 1156 if (!BugpointIsInterrupted) { 1157 outs() << "\n*** Attempting to perform final cleanups: "; 1158 Module *M = CloneModule(BD.getProgram()).release(); 1159 M = BD.performFinalCleanups(M, true).release(); 1160 1161 // Find out if the pass still crashes on the cleaned up program... 1162 if (TestFn(BD, M)) { 1163 BD.setNewProgram(M); // Yup, it does, keep the reduced version... 1164 } else { 1165 delete M; 1166 } 1167 } 1168 1169 BD.EmitProgressBitcode(BD.getProgram(), "reduced-simplified"); 1170 1171 return Error::success(); 1172 } 1173 1174 static bool TestForOptimizerCrash(const BugDriver &BD, Module *M) { 1175 return BD.runPasses(M, BD.getPassesToRun()); 1176 } 1177 1178 /// debugOptimizerCrash - This method is called when some pass crashes on input. 1179 /// It attempts to prune down the testcase to something reasonable, and figure 1180 /// out exactly which pass is crashing. 1181 /// 1182 Error BugDriver::debugOptimizerCrash(const std::string &ID) { 1183 outs() << "\n*** Debugging optimizer crash!\n"; 1184 1185 // Reduce the list of passes which causes the optimizer to crash... 1186 if (!BugpointIsInterrupted && !DontReducePassList) { 1187 Expected<bool> Result = ReducePassList(*this).reduceList(PassesToRun); 1188 if (Error E = Result.takeError()) 1189 return E; 1190 } 1191 1192 outs() << "\n*** Found crashing pass" 1193 << (PassesToRun.size() == 1 ? ": " : "es: ") 1194 << getPassesString(PassesToRun) << '\n'; 1195 1196 EmitProgressBitcode(Program, ID); 1197 1198 return DebugACrash(*this, TestForOptimizerCrash); 1199 } 1200 1201 static bool TestForCodeGenCrash(const BugDriver &BD, Module *M) { 1202 if (Error E = BD.compileProgram(M)) { 1203 if (VerboseErrors) 1204 errs() << toString(std::move(E)) << "\n"; 1205 else { 1206 consumeError(std::move(E)); 1207 errs() << "<crash>\n"; 1208 } 1209 return true; // Tool is still crashing. 1210 } 1211 errs() << '\n'; 1212 return false; 1213 } 1214 1215 /// debugCodeGeneratorCrash - This method is called when the code generator 1216 /// crashes on an input. It attempts to reduce the input as much as possible 1217 /// while still causing the code generator to crash. 1218 Error BugDriver::debugCodeGeneratorCrash() { 1219 errs() << "*** Debugging code generator crash!\n"; 1220 1221 return DebugACrash(*this, TestForCodeGenCrash); 1222 } 1223