Changeset View
Changeset View
Standalone View
Standalone View
llvm/tools/llc/llc.cpp
Show First 20 Lines • Show All 532 Lines • ▼ Show 20 Lines | if (RelaxAll.getNumOccurrences() > 0 && | ||||
if ((FileType != TargetMachine::CGFT_AssemblyFile && | if ((FileType != TargetMachine::CGFT_AssemblyFile && | ||||
!Out->os().supportsSeeking()) || | !Out->os().supportsSeeking()) || | ||||
CompileTwice) { | CompileTwice) { | ||||
BOS = std::make_unique<raw_svector_ostream>(Buffer); | BOS = std::make_unique<raw_svector_ostream>(Buffer); | ||||
OS = BOS.get(); | OS = BOS.get(); | ||||
} | } | ||||
const char *argv0 = argv[0]; | const char *argv0 = argv[0]; | ||||
LLVMTargetMachine &LLVMTM = static_cast<LLVMTargetMachine&>(*Target); | LLVMTargetMachine &LLVMTM = static_cast<LLVMTargetMachine &>(*Target); | ||||
MachineModuleInfo *MMI = new MachineModuleInfo(&LLVMTM); | MachineModuleInfoWrapperPass *MMIWP = | ||||
new MachineModuleInfoWrapperPass(&LLVMTM); | |||||
// Construct a custom pass pipeline that starts after instruction | // Construct a custom pass pipeline that starts after instruction | ||||
// selection. | // selection. | ||||
if (!RunPassNames->empty()) { | if (!RunPassNames->empty()) { | ||||
if (!MIR) { | if (!MIR) { | ||||
WithColor::warning(errs(), argv[0]) | WithColor::warning(errs(), argv[0]) | ||||
<< "run-pass is for .mir file only.\n"; | << "run-pass is for .mir file only.\n"; | ||||
return 1; | return 1; | ||||
} | } | ||||
TargetPassConfig &TPC = *LLVMTM.createPassConfig(PM); | TargetPassConfig &TPC = *LLVMTM.createPassConfig(PM); | ||||
if (TPC.hasLimitedCodeGenPipeline()) { | if (TPC.hasLimitedCodeGenPipeline()) { | ||||
WithColor::warning(errs(), argv[0]) | WithColor::warning(errs(), argv[0]) | ||||
<< "run-pass cannot be used with " | << "run-pass cannot be used with " | ||||
<< TPC.getLimitedCodeGenPipelineReason(" and ") << ".\n"; | << TPC.getLimitedCodeGenPipelineReason(" and ") << ".\n"; | ||||
return 1; | return 1; | ||||
} | } | ||||
TPC.setDisableVerify(NoVerify); | TPC.setDisableVerify(NoVerify); | ||||
PM.add(&TPC); | PM.add(&TPC); | ||||
PM.add(MMI); | PM.add(MMIWP); | ||||
TPC.printAndVerify(""); | TPC.printAndVerify(""); | ||||
for (const std::string &RunPassName : *RunPassNames) { | for (const std::string &RunPassName : *RunPassNames) { | ||||
if (addPass(PM, argv0, RunPassName, TPC)) | if (addPass(PM, argv0, RunPassName, TPC)) | ||||
return 1; | return 1; | ||||
} | } | ||||
TPC.setInitialized(); | TPC.setInitialized(); | ||||
PM.add(createPrintMIRPass(*OS)); | PM.add(createPrintMIRPass(*OS)); | ||||
PM.add(createFreeMachineFunctionPass()); | PM.add(createFreeMachineFunctionPass()); | ||||
} else if (Target->addPassesToEmitFile(PM, *OS, | } else if (Target->addPassesToEmitFile(PM, *OS, | ||||
DwoOut ? &DwoOut->os() : nullptr, | DwoOut ? &DwoOut->os() : nullptr, | ||||
FileType, NoVerify, MMI)) { | FileType, NoVerify, MMIWP)) { | ||||
WithColor::warning(errs(), argv[0]) | WithColor::warning(errs(), argv[0]) | ||||
<< "target does not support generation of this" | << "target does not support generation of this" | ||||
<< " file type!\n"; | << " file type!\n"; | ||||
return 1; | return 1; | ||||
} | } | ||||
if (MIR) { | if (MIR) { | ||||
assert(MMI && "Forgot to create MMI?"); | assert(MMIWP && "Forgot to create MMIWP?"); | ||||
if (MIR->parseMachineFunctions(*M, *MMI)) | if (MIR->parseMachineFunctions(*M, MMIWP->getMMI())) | ||||
return 1; | return 1; | ||||
arsenm: Indentation broken | |||||
} | } | ||||
// Before executing passes, print the final values of the LLVM options. | // Before executing passes, print the final values of the LLVM options. | ||||
cl::PrintOptionValues(); | cl::PrintOptionValues(); | ||||
// If requested, run the pass manager over the same module again, | // If requested, run the pass manager over the same module again, | ||||
// to catch any bugs due to persistent state in the passes. Note that | // to catch any bugs due to persistent state in the passes. Note that | ||||
// opt has the same functionality, so it may be worth abstracting this out | // opt has the same functionality, so it may be worth abstracting this out | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |
Indentation broken