1 //===- TargetPassConfig.cpp - Target independent code generation passes ---===// 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 interfaces to access the target independent code 11 // generation passes provided by the LLVM backend. 12 // 13 //===---------------------------------------------------------------------===// 14 15 #include "llvm/CodeGen/TargetPassConfig.h" 16 #include "llvm/ADT/DenseMap.h" 17 #include "llvm/ADT/SmallVector.h" 18 #include "llvm/ADT/StringRef.h" 19 #include "llvm/Analysis/BasicAliasAnalysis.h" 20 #include "llvm/Analysis/CFLAndersAliasAnalysis.h" 21 #include "llvm/Analysis/CFLSteensAliasAnalysis.h" 22 #include "llvm/Analysis/CallGraphSCCPass.h" 23 #include "llvm/Analysis/ScopedNoAliasAA.h" 24 #include "llvm/Analysis/TargetTransformInfo.h" 25 #include "llvm/Analysis/TypeBasedAliasAnalysis.h" 26 #include "llvm/CodeGen/MachineFunctionPass.h" 27 #include "llvm/CodeGen/MachinePassRegistry.h" 28 #include "llvm/CodeGen/Passes.h" 29 #include "llvm/CodeGen/RegAllocRegistry.h" 30 #include "llvm/IR/IRPrintingPasses.h" 31 #include "llvm/IR/LegacyPassManager.h" 32 #include "llvm/IR/Verifier.h" 33 #include "llvm/MC/MCAsmInfo.h" 34 #include "llvm/MC/MCTargetOptions.h" 35 #include "llvm/Pass.h" 36 #include "llvm/Support/CodeGen.h" 37 #include "llvm/Support/CommandLine.h" 38 #include "llvm/Support/Compiler.h" 39 #include "llvm/Support/Debug.h" 40 #include "llvm/Support/ErrorHandling.h" 41 #include "llvm/Support/Threading.h" 42 #include "llvm/Target/TargetMachine.h" 43 #include "llvm/Transforms/Scalar.h" 44 #include "llvm/Transforms/Utils/SymbolRewriter.h" 45 #include <cassert> 46 #include <string> 47 48 using namespace llvm; 49 50 cl::opt<bool> EnableIPRA("enable-ipra", cl::init(false), cl::Hidden, 51 cl::desc("Enable interprocedural register allocation " 52 "to reduce load/store at procedure calls.")); 53 static cl::opt<bool> DisablePostRASched("disable-post-ra", cl::Hidden, 54 cl::desc("Disable Post Regalloc Scheduler")); 55 static cl::opt<bool> DisableBranchFold("disable-branch-fold", cl::Hidden, 56 cl::desc("Disable branch folding")); 57 static cl::opt<bool> DisableTailDuplicate("disable-tail-duplicate", cl::Hidden, 58 cl::desc("Disable tail duplication")); 59 static cl::opt<bool> DisableEarlyTailDup("disable-early-taildup", cl::Hidden, 60 cl::desc("Disable pre-register allocation tail duplication")); 61 static cl::opt<bool> DisableBlockPlacement("disable-block-placement", 62 cl::Hidden, cl::desc("Disable probability-driven block placement")); 63 static cl::opt<bool> EnableBlockPlacementStats("enable-block-placement-stats", 64 cl::Hidden, cl::desc("Collect probability-driven block placement stats")); 65 static cl::opt<bool> DisableSSC("disable-ssc", cl::Hidden, 66 cl::desc("Disable Stack Slot Coloring")); 67 static cl::opt<bool> DisableMachineDCE("disable-machine-dce", cl::Hidden, 68 cl::desc("Disable Machine Dead Code Elimination")); 69 static cl::opt<bool> DisableEarlyIfConversion("disable-early-ifcvt", cl::Hidden, 70 cl::desc("Disable Early If-conversion")); 71 static cl::opt<bool> DisableMachineLICM("disable-machine-licm", cl::Hidden, 72 cl::desc("Disable Machine LICM")); 73 static cl::opt<bool> DisableMachineCSE("disable-machine-cse", cl::Hidden, 74 cl::desc("Disable Machine Common Subexpression Elimination")); 75 static cl::opt<cl::boolOrDefault> OptimizeRegAlloc( 76 "optimize-regalloc", cl::Hidden, 77 cl::desc("Enable optimized register allocation compilation path.")); 78 static cl::opt<bool> DisablePostRAMachineLICM("disable-postra-machine-licm", 79 cl::Hidden, 80 cl::desc("Disable Machine LICM")); 81 static cl::opt<bool> DisableMachineSink("disable-machine-sink", cl::Hidden, 82 cl::desc("Disable Machine Sinking")); 83 static cl::opt<bool> DisablePostRAMachineSink("disable-postra-machine-sink", 84 cl::Hidden, 85 cl::desc("Disable PostRA Machine Sinking")); 86 static cl::opt<bool> DisableLSR("disable-lsr", cl::Hidden, 87 cl::desc("Disable Loop Strength Reduction Pass")); 88 static cl::opt<bool> DisableConstantHoisting("disable-constant-hoisting", 89 cl::Hidden, cl::desc("Disable ConstantHoisting")); 90 static cl::opt<bool> DisableCGP("disable-cgp", cl::Hidden, 91 cl::desc("Disable Codegen Prepare")); 92 static cl::opt<bool> DisableCopyProp("disable-copyprop", cl::Hidden, 93 cl::desc("Disable Copy Propagation pass")); 94 static cl::opt<bool> DisablePartialLibcallInlining("disable-partial-libcall-inlining", 95 cl::Hidden, cl::desc("Disable Partial Libcall Inlining")); 96 static cl::opt<bool> EnableImplicitNullChecks( 97 "enable-implicit-null-checks", 98 cl::desc("Fold null checks into faulting memory operations"), 99 cl::init(false), cl::Hidden); 100 static cl::opt<bool> DisableMergeICmps("disable-mergeicmps", 101 cl::desc("Disable MergeICmps Pass"), 102 cl::init(false), cl::Hidden); 103 static cl::opt<bool> PrintLSR("print-lsr-output", cl::Hidden, 104 cl::desc("Print LLVM IR produced by the loop-reduce pass")); 105 static cl::opt<bool> PrintISelInput("print-isel-input", cl::Hidden, 106 cl::desc("Print LLVM IR input to isel pass")); 107 static cl::opt<bool> PrintGCInfo("print-gc", cl::Hidden, 108 cl::desc("Dump garbage collector data")); 109 static cl::opt<bool> VerifyMachineCode("verify-machineinstrs", cl::Hidden, 110 cl::desc("Verify generated machine code"), 111 cl::init(false), 112 cl::ZeroOrMore); 113 static cl::opt<bool> EnableMachineOutliner("enable-machine-outliner", 114 cl::Hidden, 115 cl::desc("Enable machine outliner")); 116 static cl::opt<bool> EnableLinkOnceODROutlining( 117 "enable-linkonceodr-outlining", 118 cl::Hidden, 119 cl::desc("Enable the machine outliner on linkonceodr functions"), 120 cl::init(false)); 121 // Enable or disable FastISel. Both options are needed, because 122 // FastISel is enabled by default with -fast, and we wish to be 123 // able to enable or disable fast-isel independently from -O0. 124 static cl::opt<cl::boolOrDefault> 125 EnableFastISelOption("fast-isel", cl::Hidden, 126 cl::desc("Enable the \"fast\" instruction selector")); 127 128 static cl::opt<cl::boolOrDefault> EnableGlobalISelOption( 129 "global-isel", cl::Hidden, 130 cl::desc("Enable the \"global\" instruction selector")); 131 132 static cl::opt<std::string> PrintMachineInstrs( 133 "print-machineinstrs", cl::ValueOptional, cl::desc("Print machine instrs"), 134 cl::value_desc("pass-name"), cl::init("option-unspecified"), cl::Hidden); 135 136 static cl::opt<int> EnableGlobalISelAbort( 137 "global-isel-abort", cl::Hidden, 138 cl::desc("Enable abort calls when \"global\" instruction selection " 139 "fails to lower/select an instruction: 0 disable the abort, " 140 "1 enable the abort, and " 141 "2 disable the abort but emit a diagnostic on failure"), 142 cl::init(1)); 143 144 // Temporary option to allow experimenting with MachineScheduler as a post-RA 145 // scheduler. Targets can "properly" enable this with 146 // substitutePass(&PostRASchedulerID, &PostMachineSchedulerID). 147 // Targets can return true in targetSchedulesPostRAScheduling() and 148 // insert a PostRA scheduling pass wherever it wants. 149 cl::opt<bool> MISchedPostRA("misched-postra", cl::Hidden, 150 cl::desc("Run MachineScheduler post regalloc (independent of preRA sched)")); 151 152 // Experimental option to run live interval analysis early. 153 static cl::opt<bool> EarlyLiveIntervals("early-live-intervals", cl::Hidden, 154 cl::desc("Run live interval analysis earlier in the pipeline")); 155 156 // Experimental option to use CFL-AA in codegen 157 enum class CFLAAType { None, Steensgaard, Andersen, Both }; 158 static cl::opt<CFLAAType> UseCFLAA( 159 "use-cfl-aa-in-codegen", cl::init(CFLAAType::None), cl::Hidden, 160 cl::desc("Enable the new, experimental CFL alias analysis in CodeGen"), 161 cl::values(clEnumValN(CFLAAType::None, "none", "Disable CFL-AA"), 162 clEnumValN(CFLAAType::Steensgaard, "steens", 163 "Enable unification-based CFL-AA"), 164 clEnumValN(CFLAAType::Andersen, "anders", 165 "Enable inclusion-based CFL-AA"), 166 clEnumValN(CFLAAType::Both, "both", 167 "Enable both variants of CFL-AA"))); 168 169 /// Option names for limiting the codegen pipeline. 170 /// Those are used in error reporting and we didn't want 171 /// to duplicate their names all over the place. 172 const char *StartAfterOptName = "start-after"; 173 const char *StartBeforeOptName = "start-before"; 174 const char *StopAfterOptName = "stop-after"; 175 const char *StopBeforeOptName = "stop-before"; 176 177 static cl::opt<std::string> 178 StartAfterOpt(StringRef(StartAfterOptName), 179 cl::desc("Resume compilation after a specific pass"), 180 cl::value_desc("pass-name"), cl::init(""), cl::Hidden); 181 182 static cl::opt<std::string> 183 StartBeforeOpt(StringRef(StartBeforeOptName), 184 cl::desc("Resume compilation before a specific pass"), 185 cl::value_desc("pass-name"), cl::init(""), cl::Hidden); 186 187 static cl::opt<std::string> 188 StopAfterOpt(StringRef(StopAfterOptName), 189 cl::desc("Stop compilation after a specific pass"), 190 cl::value_desc("pass-name"), cl::init(""), cl::Hidden); 191 192 static cl::opt<std::string> 193 StopBeforeOpt(StringRef(StopBeforeOptName), 194 cl::desc("Stop compilation before a specific pass"), 195 cl::value_desc("pass-name"), cl::init(""), cl::Hidden); 196 197 /// Allow standard passes to be disabled by command line options. This supports 198 /// simple binary flags that either suppress the pass or do nothing. 199 /// i.e. -disable-mypass=false has no effect. 200 /// These should be converted to boolOrDefault in order to use applyOverride. 201 static IdentifyingPassPtr applyDisable(IdentifyingPassPtr PassID, 202 bool Override) { 203 if (Override) 204 return IdentifyingPassPtr(); 205 return PassID; 206 } 207 208 /// Allow standard passes to be disabled by the command line, regardless of who 209 /// is adding the pass. 210 /// 211 /// StandardID is the pass identified in the standard pass pipeline and provided 212 /// to addPass(). It may be a target-specific ID in the case that the target 213 /// directly adds its own pass, but in that case we harmlessly fall through. 214 /// 215 /// TargetID is the pass that the target has configured to override StandardID. 216 /// 217 /// StandardID may be a pseudo ID. In that case TargetID is the name of the real 218 /// pass to run. This allows multiple options to control a single pass depending 219 /// on where in the pipeline that pass is added. 220 static IdentifyingPassPtr overridePass(AnalysisID StandardID, 221 IdentifyingPassPtr TargetID) { 222 if (StandardID == &PostRASchedulerID) 223 return applyDisable(TargetID, DisablePostRASched); 224 225 if (StandardID == &BranchFolderPassID) 226 return applyDisable(TargetID, DisableBranchFold); 227 228 if (StandardID == &TailDuplicateID) 229 return applyDisable(TargetID, DisableTailDuplicate); 230 231 if (StandardID == &EarlyTailDuplicateID) 232 return applyDisable(TargetID, DisableEarlyTailDup); 233 234 if (StandardID == &MachineBlockPlacementID) 235 return applyDisable(TargetID, DisableBlockPlacement); 236 237 if (StandardID == &StackSlotColoringID) 238 return applyDisable(TargetID, DisableSSC); 239 240 if (StandardID == &DeadMachineInstructionElimID) 241 return applyDisable(TargetID, DisableMachineDCE); 242 243 if (StandardID == &EarlyIfConverterID) 244 return applyDisable(TargetID, DisableEarlyIfConversion); 245 246 if (StandardID == &EarlyMachineLICMID) 247 return applyDisable(TargetID, DisableMachineLICM); 248 249 if (StandardID == &MachineCSEID) 250 return applyDisable(TargetID, DisableMachineCSE); 251 252 if (StandardID == &MachineLICMID) 253 return applyDisable(TargetID, DisablePostRAMachineLICM); 254 255 if (StandardID == &MachineSinkingID) 256 return applyDisable(TargetID, DisableMachineSink); 257 258 if (StandardID == &PostRAMachineSinkingID) 259 return applyDisable(TargetID, DisablePostRAMachineSink); 260 261 if (StandardID == &MachineCopyPropagationID) 262 return applyDisable(TargetID, DisableCopyProp); 263 264 return TargetID; 265 } 266 267 //===---------------------------------------------------------------------===// 268 /// TargetPassConfig 269 //===---------------------------------------------------------------------===// 270 271 INITIALIZE_PASS(TargetPassConfig, "targetpassconfig", 272 "Target Pass Configuration", false, false) 273 char TargetPassConfig::ID = 0; 274 275 namespace { 276 277 struct InsertedPass { 278 AnalysisID TargetPassID; 279 IdentifyingPassPtr InsertedPassID; 280 bool VerifyAfter; 281 bool PrintAfter; 282 283 InsertedPass(AnalysisID TargetPassID, IdentifyingPassPtr InsertedPassID, 284 bool VerifyAfter, bool PrintAfter) 285 : TargetPassID(TargetPassID), InsertedPassID(InsertedPassID), 286 VerifyAfter(VerifyAfter), PrintAfter(PrintAfter) {} 287 288 Pass *getInsertedPass() const { 289 assert(InsertedPassID.isValid() && "Illegal Pass ID!"); 290 if (InsertedPassID.isInstance()) 291 return InsertedPassID.getInstance(); 292 Pass *NP = Pass::createPass(InsertedPassID.getID()); 293 assert(NP && "Pass ID not registered"); 294 return NP; 295 } 296 }; 297 298 } // end anonymous namespace 299 300 namespace llvm { 301 302 class PassConfigImpl { 303 public: 304 // List of passes explicitly substituted by this target. Normally this is 305 // empty, but it is a convenient way to suppress or replace specific passes 306 // that are part of a standard pass pipeline without overridding the entire 307 // pipeline. This mechanism allows target options to inherit a standard pass's 308 // user interface. For example, a target may disable a standard pass by 309 // default by substituting a pass ID of zero, and the user may still enable 310 // that standard pass with an explicit command line option. 311 DenseMap<AnalysisID,IdentifyingPassPtr> TargetPasses; 312 313 /// Store the pairs of <AnalysisID, AnalysisID> of which the second pass 314 /// is inserted after each instance of the first one. 315 SmallVector<InsertedPass, 4> InsertedPasses; 316 }; 317 318 } // end namespace llvm 319 320 // Out of line virtual method. 321 TargetPassConfig::~TargetPassConfig() { 322 delete Impl; 323 } 324 325 static const PassInfo *getPassInfo(StringRef PassName) { 326 if (PassName.empty()) 327 return nullptr; 328 329 const PassRegistry &PR = *PassRegistry::getPassRegistry(); 330 const PassInfo *PI = PR.getPassInfo(PassName); 331 if (!PI) 332 report_fatal_error(Twine('\"') + Twine(PassName) + 333 Twine("\" pass is not registered.")); 334 return PI; 335 } 336 337 static AnalysisID getPassIDFromName(StringRef PassName) { 338 const PassInfo *PI = getPassInfo(PassName); 339 return PI ? PI->getTypeInfo() : nullptr; 340 } 341 342 void TargetPassConfig::setStartStopPasses() { 343 StartBefore = getPassIDFromName(StartBeforeOpt); 344 StartAfter = getPassIDFromName(StartAfterOpt); 345 StopBefore = getPassIDFromName(StopBeforeOpt); 346 StopAfter = getPassIDFromName(StopAfterOpt); 347 if (StartBefore && StartAfter) 348 report_fatal_error(Twine(StartBeforeOptName) + Twine(" and ") + 349 Twine(StartAfterOptName) + Twine(" specified!")); 350 if (StopBefore && StopAfter) 351 report_fatal_error(Twine(StopBeforeOptName) + Twine(" and ") + 352 Twine(StopAfterOptName) + Twine(" specified!")); 353 Started = (StartAfter == nullptr) && (StartBefore == nullptr); 354 } 355 356 // Out of line constructor provides default values for pass options and 357 // registers all common codegen passes. 358 TargetPassConfig::TargetPassConfig(LLVMTargetMachine &TM, PassManagerBase &pm) 359 : ImmutablePass(ID), PM(&pm), TM(&TM) { 360 Impl = new PassConfigImpl(); 361 362 // Register all target independent codegen passes to activate their PassIDs, 363 // including this pass itself. 364 initializeCodeGen(*PassRegistry::getPassRegistry()); 365 366 // Also register alias analysis passes required by codegen passes. 367 initializeBasicAAWrapperPassPass(*PassRegistry::getPassRegistry()); 368 initializeAAResultsWrapperPassPass(*PassRegistry::getPassRegistry()); 369 370 if (StringRef(PrintMachineInstrs.getValue()).equals("")) 371 TM.Options.PrintMachineCode = true; 372 373 if (EnableIPRA.getNumOccurrences()) 374 TM.Options.EnableIPRA = EnableIPRA; 375 else { 376 // If not explicitly specified, use target default. 377 TM.Options.EnableIPRA = TM.useIPRA(); 378 } 379 380 if (TM.Options.EnableIPRA) 381 setRequiresCodeGenSCCOrder(); 382 383 setStartStopPasses(); 384 } 385 386 CodeGenOpt::Level TargetPassConfig::getOptLevel() const { 387 return TM->getOptLevel(); 388 } 389 390 /// Insert InsertedPassID pass after TargetPassID. 391 void TargetPassConfig::insertPass(AnalysisID TargetPassID, 392 IdentifyingPassPtr InsertedPassID, 393 bool VerifyAfter, bool PrintAfter) { 394 assert(((!InsertedPassID.isInstance() && 395 TargetPassID != InsertedPassID.getID()) || 396 (InsertedPassID.isInstance() && 397 TargetPassID != InsertedPassID.getInstance()->getPassID())) && 398 "Insert a pass after itself!"); 399 Impl->InsertedPasses.emplace_back(TargetPassID, InsertedPassID, VerifyAfter, 400 PrintAfter); 401 } 402 403 /// createPassConfig - Create a pass configuration object to be used by 404 /// addPassToEmitX methods for generating a pipeline of CodeGen passes. 405 /// 406 /// Targets may override this to extend TargetPassConfig. 407 TargetPassConfig *LLVMTargetMachine::createPassConfig(PassManagerBase &PM) { 408 return new TargetPassConfig(*this, PM); 409 } 410 411 TargetPassConfig::TargetPassConfig() 412 : ImmutablePass(ID) { 413 report_fatal_error("Trying to construct TargetPassConfig without a target " 414 "machine. Scheduling a CodeGen pass without a target " 415 "triple set?"); 416 } 417 418 bool TargetPassConfig::hasLimitedCodeGenPipeline() const { 419 return StartBefore || StartAfter || StopBefore || StopAfter; 420 } 421 422 std::string 423 TargetPassConfig::getLimitedCodeGenPipelineReason(const char *Separator) const { 424 if (!hasLimitedCodeGenPipeline()) 425 return std::string(); 426 std::string Res; 427 static cl::opt<std::string> *PassNames[] = {&StartAfterOpt, &StartBeforeOpt, 428 &StopAfterOpt, &StopBeforeOpt}; 429 static const char *OptNames[] = {StartAfterOptName, StartBeforeOptName, 430 StopAfterOptName, StopBeforeOptName}; 431 bool IsFirst = true; 432 for (int Idx = 0; Idx < 4; ++Idx) 433 if (!PassNames[Idx]->empty()) { 434 if (!IsFirst) 435 Res += Separator; 436 IsFirst = false; 437 Res += OptNames[Idx]; 438 } 439 return Res; 440 } 441 442 // Helper to verify the analysis is really immutable. 443 void TargetPassConfig::setOpt(bool &Opt, bool Val) { 444 assert(!Initialized && "PassConfig is immutable"); 445 Opt = Val; 446 } 447 448 void TargetPassConfig::substitutePass(AnalysisID StandardID, 449 IdentifyingPassPtr TargetID) { 450 Impl->TargetPasses[StandardID] = TargetID; 451 } 452 453 IdentifyingPassPtr TargetPassConfig::getPassSubstitution(AnalysisID ID) const { 454 DenseMap<AnalysisID, IdentifyingPassPtr>::const_iterator 455 I = Impl->TargetPasses.find(ID); 456 if (I == Impl->TargetPasses.end()) 457 return ID; 458 return I->second; 459 } 460 461 bool TargetPassConfig::isPassSubstitutedOrOverridden(AnalysisID ID) const { 462 IdentifyingPassPtr TargetID = getPassSubstitution(ID); 463 IdentifyingPassPtr FinalPtr = overridePass(ID, TargetID); 464 return !FinalPtr.isValid() || FinalPtr.isInstance() || 465 FinalPtr.getID() != ID; 466 } 467 468 /// Add a pass to the PassManager if that pass is supposed to be run. If the 469 /// Started/Stopped flags indicate either that the compilation should start at 470 /// a later pass or that it should stop after an earlier pass, then do not add 471 /// the pass. Finally, compare the current pass against the StartAfter 472 /// and StopAfter options and change the Started/Stopped flags accordingly. 473 void TargetPassConfig::addPass(Pass *P, bool verifyAfter, bool printAfter) { 474 assert(!Initialized && "PassConfig is immutable"); 475 476 // Cache the Pass ID here in case the pass manager finds this pass is 477 // redundant with ones already scheduled / available, and deletes it. 478 // Fundamentally, once we add the pass to the manager, we no longer own it 479 // and shouldn't reference it. 480 AnalysisID PassID = P->getPassID(); 481 482 if (StartBefore == PassID) 483 Started = true; 484 if (StopBefore == PassID) 485 Stopped = true; 486 if (Started && !Stopped) { 487 std::string Banner; 488 // Construct banner message before PM->add() as that may delete the pass. 489 if (AddingMachinePasses && (printAfter || verifyAfter)) 490 Banner = std::string("After ") + std::string(P->getPassName()); 491 PM->add(P); 492 if (AddingMachinePasses) { 493 if (printAfter) 494 addPrintPass(Banner); 495 if (verifyAfter) 496 addVerifyPass(Banner); 497 } 498 499 // Add the passes after the pass P if there is any. 500 for (auto IP : Impl->InsertedPasses) { 501 if (IP.TargetPassID == PassID) 502 addPass(IP.getInsertedPass(), IP.VerifyAfter, IP.PrintAfter); 503 } 504 } else { 505 delete P; 506 } 507 if (StopAfter == PassID) 508 Stopped = true; 509 if (StartAfter == PassID) 510 Started = true; 511 if (Stopped && !Started) 512 report_fatal_error("Cannot stop compilation after pass that is not run"); 513 } 514 515 /// Add a CodeGen pass at this point in the pipeline after checking for target 516 /// and command line overrides. 517 /// 518 /// addPass cannot return a pointer to the pass instance because is internal the 519 /// PassManager and the instance we create here may already be freed. 520 AnalysisID TargetPassConfig::addPass(AnalysisID PassID, bool verifyAfter, 521 bool printAfter) { 522 IdentifyingPassPtr TargetID = getPassSubstitution(PassID); 523 IdentifyingPassPtr FinalPtr = overridePass(PassID, TargetID); 524 if (!FinalPtr.isValid()) 525 return nullptr; 526 527 Pass *P; 528 if (FinalPtr.isInstance()) 529 P = FinalPtr.getInstance(); 530 else { 531 P = Pass::createPass(FinalPtr.getID()); 532 if (!P) 533 llvm_unreachable("Pass ID not registered"); 534 } 535 AnalysisID FinalID = P->getPassID(); 536 addPass(P, verifyAfter, printAfter); // Ends the lifetime of P. 537 538 return FinalID; 539 } 540 541 void TargetPassConfig::printAndVerify(const std::string &Banner) { 542 addPrintPass(Banner); 543 addVerifyPass(Banner); 544 } 545 546 void TargetPassConfig::addPrintPass(const std::string &Banner) { 547 if (TM->shouldPrintMachineCode()) 548 PM->add(createMachineFunctionPrinterPass(dbgs(), Banner)); 549 } 550 551 void TargetPassConfig::addVerifyPass(const std::string &Banner) { 552 bool Verify = VerifyMachineCode; 553 #ifdef EXPENSIVE_CHECKS 554 if (VerifyMachineCode == cl::BOU_UNSET) 555 Verify = TM->isMachineVerifierClean(); 556 #endif 557 if (Verify) 558 PM->add(createMachineVerifierPass(Banner)); 559 } 560 561 /// Add common target configurable passes that perform LLVM IR to IR transforms 562 /// following machine independent optimization. 563 void TargetPassConfig::addIRPasses() { 564 switch (UseCFLAA) { 565 case CFLAAType::Steensgaard: 566 addPass(createCFLSteensAAWrapperPass()); 567 break; 568 case CFLAAType::Andersen: 569 addPass(createCFLAndersAAWrapperPass()); 570 break; 571 case CFLAAType::Both: 572 addPass(createCFLAndersAAWrapperPass()); 573 addPass(createCFLSteensAAWrapperPass()); 574 break; 575 default: 576 break; 577 } 578 579 // Basic AliasAnalysis support. 580 // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that 581 // BasicAliasAnalysis wins if they disagree. This is intended to help 582 // support "obvious" type-punning idioms. 583 addPass(createTypeBasedAAWrapperPass()); 584 addPass(createScopedNoAliasAAWrapperPass()); 585 addPass(createBasicAAWrapperPass()); 586 587 // Before running any passes, run the verifier to determine if the input 588 // coming from the front-end and/or optimizer is valid. 589 if (!DisableVerify) 590 addPass(createVerifierPass()); 591 592 // Run loop strength reduction before anything else. 593 if (getOptLevel() != CodeGenOpt::None && !DisableLSR) { 594 addPass(createLoopStrengthReducePass()); 595 if (PrintLSR) 596 addPass(createPrintFunctionPass(dbgs(), "\n\n*** Code after LSR ***\n")); 597 } 598 599 if (getOptLevel() != CodeGenOpt::None) { 600 // The MergeICmpsPass tries to create memcmp calls by grouping sequences of 601 // loads and compares. ExpandMemCmpPass then tries to expand those calls 602 // into optimally-sized loads and compares. The transforms are enabled by a 603 // target lowering hook. 604 if (!DisableMergeICmps) 605 addPass(createMergeICmpsPass()); 606 addPass(createExpandMemCmpPass()); 607 } 608 609 // Run GC lowering passes for builtin collectors 610 // TODO: add a pass insertion point here 611 addPass(createGCLoweringPass()); 612 addPass(createShadowStackGCLoweringPass()); 613 614 // Make sure that no unreachable blocks are instruction selected. 615 addPass(createUnreachableBlockEliminationPass()); 616 617 // Prepare expensive constants for SelectionDAG. 618 if (getOptLevel() != CodeGenOpt::None && !DisableConstantHoisting) 619 addPass(createConstantHoistingPass()); 620 621 if (getOptLevel() != CodeGenOpt::None && !DisablePartialLibcallInlining) 622 addPass(createPartiallyInlineLibCallsPass()); 623 624 // Instrument function entry and exit, e.g. with calls to mcount(). 625 addPass(createPostInlineEntryExitInstrumenterPass()); 626 627 // Add scalarization of target's unsupported masked memory intrinsics pass. 628 // the unsupported intrinsic will be replaced with a chain of basic blocks, 629 // that stores/loads element one-by-one if the appropriate mask bit is set. 630 addPass(createScalarizeMaskedMemIntrinPass()); 631 632 // Expand reduction intrinsics into shuffle sequences if the target wants to. 633 addPass(createExpandReductionsPass()); 634 } 635 636 /// Turn exception handling constructs into something the code generators can 637 /// handle. 638 void TargetPassConfig::addPassesToHandleExceptions() { 639 const MCAsmInfo *MCAI = TM->getMCAsmInfo(); 640 assert(MCAI && "No MCAsmInfo"); 641 switch (MCAI->getExceptionHandlingType()) { 642 case ExceptionHandling::SjLj: 643 // SjLj piggy-backs on dwarf for this bit. The cleanups done apply to both 644 // Dwarf EH prepare needs to be run after SjLj prepare. Otherwise, 645 // catch info can get misplaced when a selector ends up more than one block 646 // removed from the parent invoke(s). This could happen when a landing 647 // pad is shared by multiple invokes and is also a target of a normal 648 // edge from elsewhere. 649 addPass(createSjLjEHPreparePass()); 650 LLVM_FALLTHROUGH; 651 case ExceptionHandling::DwarfCFI: 652 case ExceptionHandling::ARM: 653 addPass(createDwarfEHPass()); 654 break; 655 case ExceptionHandling::WinEH: 656 // We support using both GCC-style and MSVC-style exceptions on Windows, so 657 // add both preparation passes. Each pass will only actually run if it 658 // recognizes the personality function. 659 addPass(createWinEHPass()); 660 addPass(createDwarfEHPass()); 661 break; 662 case ExceptionHandling::Wasm: 663 // TODO to prevent warning 664 break; 665 case ExceptionHandling::None: 666 addPass(createLowerInvokePass()); 667 668 // The lower invoke pass may create unreachable code. Remove it. 669 addPass(createUnreachableBlockEliminationPass()); 670 break; 671 } 672 } 673 674 /// Add pass to prepare the LLVM IR for code generation. This should be done 675 /// before exception handling preparation passes. 676 void TargetPassConfig::addCodeGenPrepare() { 677 if (getOptLevel() != CodeGenOpt::None && !DisableCGP) 678 addPass(createCodeGenPreparePass()); 679 addPass(createRewriteSymbolsPass()); 680 } 681 682 /// Add common passes that perform LLVM IR to IR transforms in preparation for 683 /// instruction selection. 684 void TargetPassConfig::addISelPrepare() { 685 addPreISel(); 686 687 // Force codegen to run according to the callgraph. 688 if (requiresCodeGenSCCOrder()) 689 addPass(new DummyCGSCCPass); 690 691 // Add both the safe stack and the stack protection passes: each of them will 692 // only protect functions that have corresponding attributes. 693 addPass(createSafeStackPass()); 694 addPass(createStackProtectorPass()); 695 696 if (PrintISelInput) 697 addPass(createPrintFunctionPass( 698 dbgs(), "\n\n*** Final LLVM Code input to ISel ***\n")); 699 700 // All passes which modify the LLVM IR are now complete; run the verifier 701 // to ensure that the IR is valid. 702 if (!DisableVerify) 703 addPass(createVerifierPass()); 704 } 705 706 bool TargetPassConfig::addCoreISelPasses() { 707 // Enable FastISel with -fast-isel, but allow that to be overridden. 708 TM->setO0WantsFastISel(EnableFastISelOption != cl::BOU_FALSE); 709 if (EnableFastISelOption == cl::BOU_TRUE || 710 (TM->getOptLevel() == CodeGenOpt::None && TM->getO0WantsFastISel())) 711 TM->setFastISel(true); 712 713 // Ask the target for an instruction selector. 714 // Explicitly enabling fast-isel should override implicitly enabled 715 // global-isel. 716 if (EnableGlobalISelOption == cl::BOU_TRUE || 717 (EnableGlobalISelOption == cl::BOU_UNSET && 718 TM->Options.EnableGlobalISel && EnableFastISelOption != cl::BOU_TRUE)) { 719 TM->setFastISel(false); 720 721 if (addIRTranslator()) 722 return true; 723 724 addPreLegalizeMachineIR(); 725 726 if (addLegalizeMachineIR()) 727 return true; 728 729 // Before running the register bank selector, ask the target if it 730 // wants to run some passes. 731 addPreRegBankSelect(); 732 733 if (addRegBankSelect()) 734 return true; 735 736 addPreGlobalInstructionSelect(); 737 738 if (addGlobalInstructionSelect()) 739 return true; 740 741 // Pass to reset the MachineFunction if the ISel failed. 742 addPass(createResetMachineFunctionPass( 743 reportDiagnosticWhenGlobalISelFallback(), isGlobalISelAbortEnabled())); 744 745 // Provide a fallback path when we do not want to abort on 746 // not-yet-supported input. 747 if (!isGlobalISelAbortEnabled() && addInstSelector()) 748 return true; 749 750 } else if (addInstSelector()) 751 return true; 752 753 return false; 754 } 755 756 bool TargetPassConfig::addISelPasses() { 757 if (TM->useEmulatedTLS()) 758 addPass(createLowerEmuTLSPass()); 759 760 addPass(createPreISelIntrinsicLoweringPass()); 761 addPass(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis())); 762 addIRPasses(); 763 addCodeGenPrepare(); 764 addPassesToHandleExceptions(); 765 addISelPrepare(); 766 767 return addCoreISelPasses(); 768 } 769 770 /// -regalloc=... command line option. 771 static FunctionPass *useDefaultRegisterAllocator() { return nullptr; } 772 static cl::opt<RegisterRegAlloc::FunctionPassCtor, false, 773 RegisterPassParser<RegisterRegAlloc>> 774 RegAlloc("regalloc", cl::Hidden, cl::init(&useDefaultRegisterAllocator), 775 cl::desc("Register allocator to use")); 776 777 /// Add the complete set of target-independent postISel code generator passes. 778 /// 779 /// This can be read as the standard order of major LLVM CodeGen stages. Stages 780 /// with nontrivial configuration or multiple passes are broken out below in 781 /// add%Stage routines. 782 /// 783 /// Any TargetPassConfig::addXX routine may be overriden by the Target. The 784 /// addPre/Post methods with empty header implementations allow injecting 785 /// target-specific fixups just before or after major stages. Additionally, 786 /// targets have the flexibility to change pass order within a stage by 787 /// overriding default implementation of add%Stage routines below. Each 788 /// technique has maintainability tradeoffs because alternate pass orders are 789 /// not well supported. addPre/Post works better if the target pass is easily 790 /// tied to a common pass. But if it has subtle dependencies on multiple passes, 791 /// the target should override the stage instead. 792 /// 793 /// TODO: We could use a single addPre/Post(ID) hook to allow pass injection 794 /// before/after any target-independent pass. But it's currently overkill. 795 void TargetPassConfig::addMachinePasses() { 796 AddingMachinePasses = true; 797 798 // Insert a machine instr printer pass after the specified pass. 799 if (!StringRef(PrintMachineInstrs.getValue()).equals("") && 800 !StringRef(PrintMachineInstrs.getValue()).equals("option-unspecified")) { 801 const PassRegistry *PR = PassRegistry::getPassRegistry(); 802 const PassInfo *TPI = PR->getPassInfo(PrintMachineInstrs.getValue()); 803 const PassInfo *IPI = PR->getPassInfo(StringRef("machineinstr-printer")); 804 assert (TPI && IPI && "Pass ID not registered!"); 805 const char *TID = (const char *)(TPI->getTypeInfo()); 806 const char *IID = (const char *)(IPI->getTypeInfo()); 807 insertPass(TID, IID); 808 } 809 810 // Print the instruction selected machine code... 811 printAndVerify("After Instruction Selection"); 812 813 // Expand pseudo-instructions emitted by ISel. 814 addPass(&ExpandISelPseudosID); 815 816 // Add passes that optimize machine instructions in SSA form. 817 if (getOptLevel() != CodeGenOpt::None) { 818 addMachineSSAOptimization(); 819 } else { 820 // If the target requests it, assign local variables to stack slots relative 821 // to one another and simplify frame index references where possible. 822 addPass(&LocalStackSlotAllocationID, false); 823 } 824 825 if (TM->Options.EnableIPRA) 826 addPass(createRegUsageInfoPropPass()); 827 828 // Run pre-ra passes. 829 addPreRegAlloc(); 830 831 // Run register allocation and passes that are tightly coupled with it, 832 // including phi elimination and scheduling. 833 if (getOptimizeRegAlloc()) 834 addOptimizedRegAlloc(createRegAllocPass(true)); 835 else { 836 if (RegAlloc != &useDefaultRegisterAllocator && 837 RegAlloc != &createFastRegisterAllocator) 838 report_fatal_error("Must use fast (default) register allocator for unoptimized regalloc."); 839 addFastRegAlloc(createRegAllocPass(false)); 840 } 841 842 // Run post-ra passes. 843 addPostRegAlloc(); 844 845 // Insert prolog/epilog code. Eliminate abstract frame index references... 846 if (getOptLevel() != CodeGenOpt::None) { 847 addPass(&PostRAMachineSinkingID); 848 addPass(&ShrinkWrapID); 849 } 850 851 // Prolog/Epilog inserter needs a TargetMachine to instantiate. But only 852 // do so if it hasn't been disabled, substituted, or overridden. 853 if (!isPassSubstitutedOrOverridden(&PrologEpilogCodeInserterID)) 854 addPass(createPrologEpilogInserterPass()); 855 856 /// Add passes that optimize machine instructions after register allocation. 857 if (getOptLevel() != CodeGenOpt::None) 858 addMachineLateOptimization(); 859 860 // Expand pseudo instructions before second scheduling pass. 861 addPass(&ExpandPostRAPseudosID); 862 863 // Run pre-sched2 passes. 864 addPreSched2(); 865 866 if (EnableImplicitNullChecks) 867 addPass(&ImplicitNullChecksID); 868 869 // Second pass scheduler. 870 // Let Target optionally insert this pass by itself at some other 871 // point. 872 if (getOptLevel() != CodeGenOpt::None && 873 !TM->targetSchedulesPostRAScheduling()) { 874 if (MISchedPostRA) 875 addPass(&PostMachineSchedulerID); 876 else 877 addPass(&PostRASchedulerID); 878 } 879 880 // GC 881 if (addGCPasses()) { 882 if (PrintGCInfo) 883 addPass(createGCInfoPrinter(dbgs()), false, false); 884 } 885 886 // Basic block placement. 887 if (getOptLevel() != CodeGenOpt::None) 888 addBlockPlacement(); 889 890 addPreEmitPass(); 891 892 if (TM->Options.EnableIPRA) 893 // Collect register usage information and produce a register mask of 894 // clobbered registers, to be used to optimize call sites. 895 addPass(createRegUsageInfoCollector()); 896 897 addPass(&FuncletLayoutID, false); 898 899 addPass(&StackMapLivenessID, false); 900 addPass(&LiveDebugValuesID, false); 901 902 // Insert before XRay Instrumentation. 903 addPass(&FEntryInserterID, false); 904 905 addPass(&XRayInstrumentationID, false); 906 addPass(&PatchableFunctionID, false); 907 908 if (EnableMachineOutliner) 909 PM->add(createMachineOutlinerPass(EnableLinkOnceODROutlining)); 910 911 // Add passes that directly emit MI after all other MI passes. 912 addPreEmitPass2(); 913 914 AddingMachinePasses = false; 915 } 916 917 /// Add passes that optimize machine instructions in SSA form. 918 void TargetPassConfig::addMachineSSAOptimization() { 919 // Pre-ra tail duplication. 920 addPass(&EarlyTailDuplicateID); 921 922 // Optimize PHIs before DCE: removing dead PHI cycles may make more 923 // instructions dead. 924 addPass(&OptimizePHIsID, false); 925 926 // This pass merges large allocas. StackSlotColoring is a different pass 927 // which merges spill slots. 928 addPass(&StackColoringID, false); 929 930 // If the target requests it, assign local variables to stack slots relative 931 // to one another and simplify frame index references where possible. 932 addPass(&LocalStackSlotAllocationID, false); 933 934 // With optimization, dead code should already be eliminated. However 935 // there is one known exception: lowered code for arguments that are only 936 // used by tail calls, where the tail calls reuse the incoming stack 937 // arguments directly (see t11 in test/CodeGen/X86/sibcall.ll). 938 addPass(&DeadMachineInstructionElimID); 939 940 // Allow targets to insert passes that improve instruction level parallelism, 941 // like if-conversion. Such passes will typically need dominator trees and 942 // loop info, just like LICM and CSE below. 943 addILPOpts(); 944 945 addPass(&EarlyMachineLICMID, false); 946 addPass(&MachineCSEID, false); 947 948 addPass(&MachineSinkingID); 949 950 addPass(&PeepholeOptimizerID); 951 // Clean-up the dead code that may have been generated by peephole 952 // rewriting. 953 addPass(&DeadMachineInstructionElimID); 954 } 955 956 //===---------------------------------------------------------------------===// 957 /// Register Allocation Pass Configuration 958 //===---------------------------------------------------------------------===// 959 960 bool TargetPassConfig::getOptimizeRegAlloc() const { 961 switch (OptimizeRegAlloc) { 962 case cl::BOU_UNSET: return getOptLevel() != CodeGenOpt::None; 963 case cl::BOU_TRUE: return true; 964 case cl::BOU_FALSE: return false; 965 } 966 llvm_unreachable("Invalid optimize-regalloc state"); 967 } 968 969 /// RegisterRegAlloc's global Registry tracks allocator registration. 970 MachinePassRegistry RegisterRegAlloc::Registry; 971 972 /// A dummy default pass factory indicates whether the register allocator is 973 /// overridden on the command line. 974 static llvm::once_flag InitializeDefaultRegisterAllocatorFlag; 975 976 static RegisterRegAlloc 977 defaultRegAlloc("default", 978 "pick register allocator based on -O option", 979 useDefaultRegisterAllocator); 980 981 static void initializeDefaultRegisterAllocatorOnce() { 982 RegisterRegAlloc::FunctionPassCtor Ctor = RegisterRegAlloc::getDefault(); 983 984 if (!Ctor) { 985 Ctor = RegAlloc; 986 RegisterRegAlloc::setDefault(RegAlloc); 987 } 988 } 989 990 /// Instantiate the default register allocator pass for this target for either 991 /// the optimized or unoptimized allocation path. This will be added to the pass 992 /// manager by addFastRegAlloc in the unoptimized case or addOptimizedRegAlloc 993 /// in the optimized case. 994 /// 995 /// A target that uses the standard regalloc pass order for fast or optimized 996 /// allocation may still override this for per-target regalloc 997 /// selection. But -regalloc=... always takes precedence. 998 FunctionPass *TargetPassConfig::createTargetRegisterAllocator(bool Optimized) { 999 if (Optimized) 1000 return createGreedyRegisterAllocator(); 1001 else 1002 return createFastRegisterAllocator(); 1003 } 1004 1005 /// Find and instantiate the register allocation pass requested by this target 1006 /// at the current optimization level. Different register allocators are 1007 /// defined as separate passes because they may require different analysis. 1008 /// 1009 /// This helper ensures that the regalloc= option is always available, 1010 /// even for targets that override the default allocator. 1011 /// 1012 /// FIXME: When MachinePassRegistry register pass IDs instead of function ptrs, 1013 /// this can be folded into addPass. 1014 FunctionPass *TargetPassConfig::createRegAllocPass(bool Optimized) { 1015 // Initialize the global default. 1016 llvm::call_once(InitializeDefaultRegisterAllocatorFlag, 1017 initializeDefaultRegisterAllocatorOnce); 1018 1019 RegisterRegAlloc::FunctionPassCtor Ctor = RegisterRegAlloc::getDefault(); 1020 if (Ctor != useDefaultRegisterAllocator) 1021 return Ctor(); 1022 1023 // With no -regalloc= override, ask the target for a regalloc pass. 1024 return createTargetRegisterAllocator(Optimized); 1025 } 1026 1027 /// Return true if the default global register allocator is in use and 1028 /// has not be overriden on the command line with '-regalloc=...' 1029 bool TargetPassConfig::usingDefaultRegAlloc() const { 1030 return RegAlloc.getNumOccurrences() == 0; 1031 } 1032 1033 /// Add the minimum set of target-independent passes that are required for 1034 /// register allocation. No coalescing or scheduling. 1035 void TargetPassConfig::addFastRegAlloc(FunctionPass *RegAllocPass) { 1036 addPass(&PHIEliminationID, false); 1037 addPass(&TwoAddressInstructionPassID, false); 1038 1039 if (RegAllocPass) 1040 addPass(RegAllocPass); 1041 } 1042 1043 /// Add standard target-independent passes that are tightly coupled with 1044 /// optimized register allocation, including coalescing, machine instruction 1045 /// scheduling, and register allocation itself. 1046 void TargetPassConfig::addOptimizedRegAlloc(FunctionPass *RegAllocPass) { 1047 addPass(&DetectDeadLanesID, false); 1048 1049 addPass(&ProcessImplicitDefsID, false); 1050 1051 // LiveVariables currently requires pure SSA form. 1052 // 1053 // FIXME: Once TwoAddressInstruction pass no longer uses kill flags, 1054 // LiveVariables can be removed completely, and LiveIntervals can be directly 1055 // computed. (We still either need to regenerate kill flags after regalloc, or 1056 // preferably fix the scavenger to not depend on them). 1057 addPass(&LiveVariablesID, false); 1058 1059 // Edge splitting is smarter with machine loop info. 1060 addPass(&MachineLoopInfoID, false); 1061 addPass(&PHIEliminationID, false); 1062 1063 // Eventually, we want to run LiveIntervals before PHI elimination. 1064 if (EarlyLiveIntervals) 1065 addPass(&LiveIntervalsID, false); 1066 1067 addPass(&TwoAddressInstructionPassID, false); 1068 addPass(&RegisterCoalescerID); 1069 1070 // The machine scheduler may accidentally create disconnected components 1071 // when moving subregister definitions around, avoid this by splitting them to 1072 // separate vregs before. Splitting can also improve reg. allocation quality. 1073 addPass(&RenameIndependentSubregsID); 1074 1075 // PreRA instruction scheduling. 1076 addPass(&MachineSchedulerID); 1077 1078 if (RegAllocPass) { 1079 // Add the selected register allocation pass. 1080 addPass(RegAllocPass); 1081 1082 // Allow targets to change the register assignments before rewriting. 1083 addPreRewrite(); 1084 1085 // Finally rewrite virtual registers. 1086 addPass(&VirtRegRewriterID); 1087 1088 // Perform stack slot coloring and post-ra machine LICM. 1089 // 1090 // FIXME: Re-enable coloring with register when it's capable of adding 1091 // kill markers. 1092 addPass(&StackSlotColoringID); 1093 1094 // Copy propagate to forward register uses and try to eliminate COPYs that 1095 // were not coalesced. 1096 addPass(&MachineCopyPropagationID); 1097 1098 // Run post-ra machine LICM to hoist reloads / remats. 1099 // 1100 // FIXME: can this move into MachineLateOptimization? 1101 addPass(&MachineLICMID); 1102 } 1103 } 1104 1105 //===---------------------------------------------------------------------===// 1106 /// Post RegAlloc Pass Configuration 1107 //===---------------------------------------------------------------------===// 1108 1109 /// Add passes that optimize machine instructions after register allocation. 1110 void TargetPassConfig::addMachineLateOptimization() { 1111 // Branch folding must be run after regalloc and prolog/epilog insertion. 1112 addPass(&BranchFolderPassID); 1113 1114 // Tail duplication. 1115 // Note that duplicating tail just increases code size and degrades 1116 // performance for targets that require Structured Control Flow. 1117 // In addition it can also make CFG irreducible. Thus we disable it. 1118 if (!TM->requiresStructuredCFG()) 1119 addPass(&TailDuplicateID); 1120 1121 // Copy propagation. 1122 addPass(&MachineCopyPropagationID); 1123 } 1124 1125 /// Add standard GC passes. 1126 bool TargetPassConfig::addGCPasses() { 1127 addPass(&GCMachineCodeAnalysisID, false); 1128 return true; 1129 } 1130 1131 /// Add standard basic block placement passes. 1132 void TargetPassConfig::addBlockPlacement() { 1133 if (addPass(&MachineBlockPlacementID)) { 1134 // Run a separate pass to collect block placement statistics. 1135 if (EnableBlockPlacementStats) 1136 addPass(&MachineBlockPlacementStatsID); 1137 } 1138 } 1139 1140 //===---------------------------------------------------------------------===// 1141 /// GlobalISel Configuration 1142 //===---------------------------------------------------------------------===// 1143 bool TargetPassConfig::isGlobalISelAbortEnabled() const { 1144 if (EnableGlobalISelAbort.getNumOccurrences() > 0) 1145 return EnableGlobalISelAbort == 1; 1146 1147 // When no abort behaviour is specified, we don't abort if the target says 1148 // that GISel is enabled. 1149 return !TM->Options.EnableGlobalISel; 1150 } 1151 1152 bool TargetPassConfig::reportDiagnosticWhenGlobalISelFallback() const { 1153 return EnableGlobalISelAbort == 2; 1154 } 1155