diff options
| author | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2019-06-14 00:05:56 +0000 |
|---|---|---|
| committer | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2019-06-14 00:05:56 +0000 |
| commit | e4147ea1ef4d24e266f71a2700fa7478d2fdc6ba (patch) | |
| tree | a3c3123cebc1d13386b8e2e9c621e0741c506b5a /llvm/tools/opt | |
| parent | 1e4882c8906f3a31031e47dd5010f4078a9c4702 (diff) | |
| download | bcm5719-llvm-e4147ea1ef4d24e266f71a2700fa7478d2fdc6ba.tar.gz bcm5719-llvm-e4147ea1ef4d24e266f71a2700fa7478d2fdc6ba.zip | |
Revert "[Remarks] Refactor optimization remarks setup"
This reverts commit 6e6e3af55bb97e1a4c97375c15a2b0099120c5a7.
This breaks greendragon.
llvm-svn: 363343
Diffstat (limited to 'llvm/tools/opt')
| -rw-r--r-- | llvm/tools/opt/opt.cpp | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index dde1d776fef..4410b4c1679 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -251,20 +251,19 @@ static cl::opt<bool> Coroutines( cl::desc("Enable coroutine passes."), cl::init(false), cl::Hidden); -static cl::opt<bool> RemarksWithHotness( +static cl::opt<bool> PassRemarksWithHotness( "pass-remarks-with-hotness", cl::desc("With PGO, include profile count in optimization remarks"), cl::Hidden); -static cl::opt<unsigned> - RemarksHotnessThreshold("pass-remarks-hotness-threshold", - cl::desc("Minimum profile count required for " - "an optimization remark to be output"), - cl::Hidden); +static cl::opt<unsigned> PassRemarksHotnessThreshold( + "pass-remarks-hotness-threshold", + cl::desc("Minimum profile count required for an optimization remark to be output"), + cl::Hidden); static cl::opt<std::string> RemarksFilename("pass-remarks-output", - cl::desc("Output filename for pass remarks"), + cl::desc("YAML output filename for pass remarks"), cl::value_desc("filename")); static cl::opt<std::string> @@ -550,14 +549,31 @@ int main(int argc, char **argv) { if (!DisableDITypeMap) Context.enableDebugTypeODRUniquing(); - Expected<std::unique_ptr<ToolOutputFile>> RemarksFileOrErr = - setupOptimizationRemarks(Context, RemarksFilename, RemarksPasses, - RemarksWithHotness, RemarksHotnessThreshold); - if (Error E = RemarksFileOrErr.takeError()) { - errs() << toString(std::move(E)) << '\n'; - return 1; + if (PassRemarksWithHotness) + Context.setDiagnosticsHotnessRequested(true); + + if (PassRemarksHotnessThreshold) + Context.setDiagnosticsHotnessThreshold(PassRemarksHotnessThreshold); + + std::unique_ptr<ToolOutputFile> OptRemarkFile; + if (RemarksFilename != "") { + std::error_code EC; + OptRemarkFile = + llvm::make_unique<ToolOutputFile>(RemarksFilename, EC, sys::fs::F_None); + if (EC) { + errs() << EC.message() << '\n'; + return 1; + } + Context.setRemarkStreamer(llvm::make_unique<RemarkStreamer>( + RemarksFilename, + llvm::make_unique<remarks::YAMLSerializer>(OptRemarkFile->os()))); + + if (!RemarksPasses.empty()) + if (Error E = Context.getRemarkStreamer()->setFilter(RemarksPasses)) { + errs() << E << '\n'; + return 1; + } } - std::unique_ptr<ToolOutputFile> RemarksFile = std::move(*RemarksFileOrErr); // Load the input module... std::unique_ptr<Module> M = @@ -671,7 +687,7 @@ int main(int argc, char **argv) { // string. Hand off the rest of the functionality to the new code for that // layer. return runPassPipeline(argv[0], *M, TM.get(), Out.get(), ThinLinkOut.get(), - RemarksFile.get(), PassPipeline, OK, VK, + OptRemarkFile.get(), PassPipeline, OK, VK, PreserveAssemblyUseListOrder, PreserveBitcodeUseListOrder, EmitSummaryIndex, EmitModuleHash, EnableDebugify) @@ -907,8 +923,8 @@ int main(int argc, char **argv) { "the compile-twice option\n"; Out->os() << BOS->str(); Out->keep(); - if (RemarksFile) - RemarksFile->keep(); + if (OptRemarkFile) + OptRemarkFile->keep(); return 1; } Out->os() << BOS->str(); @@ -921,8 +937,8 @@ int main(int argc, char **argv) { if (!NoOutput || PrintBreakpoints) Out->keep(); - if (RemarksFile) - RemarksFile->keep(); + if (OptRemarkFile) + OptRemarkFile->keep(); if (ThinLinkOut) ThinLinkOut->keep(); |

