summaryrefslogtreecommitdiff
path: root/tools/opt
diff options
context:
space:
mode:
authorSam Elliott <ashe2@cs.washington.edu>2017-08-20 01:30:45 +0000
committerSam Elliott <ashe2@cs.washington.edu>2017-08-20 01:30:45 +0000
commit74a34d9193e1d5027785b1fed7a30a2f18c731a6 (patch)
tree16bcef0926855af32bca6fab753c001db005ac96 /tools/opt
parente12236f216fd10580c830e4cd5c7ec7cd283ee03 (diff)
Keep Optimization Remark Yaml in NewPM
Summary: The New Pass Manager infrastructure was forgetting to keep around the optimization remark yaml file that the compiler might have been producing. This meant setting the option to '-' for stdout worked, but setting it to a filename didn't give file output (presumably it was deleted because compilation didn't explicitly keep it). This change just ensures that the file is kept if compilation succeeds. So far I have updated one of the optimization remark output tests to add a version with the new pass manager. It is my intention for this patch to also include changes to all tests that use `-opt-remark-output=` but I wanted to get the code patch ready for review while I was making all those changes. Fixes https://bugs.llvm.org/show_bug.cgi?id=33951 Reviewers: anemet, chandlerc Reviewed By: anemet, chandlerc Subscribers: javed.absar, chandlerc, fhahn, llvm-commits Differential Revision: https://reviews.llvm.org/D36906 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311271 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/opt')
-rw-r--r--tools/opt/NewPMDriver.cpp5
-rw-r--r--tools/opt/NewPMDriver.h4
-rw-r--r--tools/opt/opt.cpp19
3 files changed, 17 insertions, 11 deletions
diff --git a/tools/opt/NewPMDriver.cpp b/tools/opt/NewPMDriver.cpp
index f46d37ee8c7..3ce33fd729e 100644
--- a/tools/opt/NewPMDriver.cpp
+++ b/tools/opt/NewPMDriver.cpp
@@ -170,6 +170,7 @@ void RegisterPollyPasses(PassBuilder &);
bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
tool_output_file *Out,
tool_output_file *ThinLTOLinkOut,
+ tool_output_file *OptRemarkFile,
StringRef PassPipeline, OutputKind OK,
VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
@@ -266,5 +267,9 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
if (OK == OK_OutputThinLTOBitcode && ThinLTOLinkOut)
ThinLTOLinkOut->keep();
}
+
+ if (OptRemarkFile)
+ OptRemarkFile->keep();
+
return true;
}
diff --git a/tools/opt/NewPMDriver.h b/tools/opt/NewPMDriver.h
index 8012e0a025c..88184f1aabc 100644
--- a/tools/opt/NewPMDriver.h
+++ b/tools/opt/NewPMDriver.h
@@ -53,8 +53,8 @@ enum VerifierKind {
/// nullptr.
bool runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
tool_output_file *Out, tool_output_file *ThinLinkOut,
- StringRef PassPipeline, opt_tool::OutputKind OK,
- opt_tool::VerifierKind VK,
+ tool_output_file *OptRemarkFile, StringRef PassPipeline,
+ opt_tool::OutputKind OK, opt_tool::VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
bool EmitSummaryIndex, bool EmitModuleHash);
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 7bbdb7ebb23..4c7d090097a 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -430,17 +430,17 @@ int main(int argc, char **argv) {
if (PassRemarksHotnessThreshold)
Context.setDiagnosticsHotnessThreshold(PassRemarksHotnessThreshold);
- std::unique_ptr<tool_output_file> YamlFile;
+ std::unique_ptr<tool_output_file> OptRemarkFile;
if (RemarksFilename != "") {
std::error_code EC;
- YamlFile = llvm::make_unique<tool_output_file>(RemarksFilename, EC,
- sys::fs::F_None);
+ OptRemarkFile = llvm::make_unique<tool_output_file>(RemarksFilename, EC,
+ sys::fs::F_None);
if (EC) {
errs() << EC.message() << '\n';
return 1;
}
Context.setDiagnosticsOutputFile(
- llvm::make_unique<yaml::Output>(YamlFile->os()));
+ llvm::make_unique<yaml::Output>(OptRemarkFile->os()));
}
// Load the input module...
@@ -540,7 +540,8 @@ 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(),
- PassPipeline, OK, VK, PreserveAssemblyUseListOrder,
+ OptRemarkFile.get(), PassPipeline, OK, VK,
+ PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex,
EmitModuleHash)
? 0
@@ -767,8 +768,8 @@ int main(int argc, char **argv) {
"the compile-twice option\n";
Out->os() << BOS->str();
Out->keep();
- if (YamlFile)
- YamlFile->keep();
+ if (OptRemarkFile)
+ OptRemarkFile->keep();
return 1;
}
Out->os() << BOS->str();
@@ -778,8 +779,8 @@ int main(int argc, char **argv) {
if (!NoOutput || PrintBreakpoints)
Out->keep();
- if (YamlFile)
- YamlFile->keep();
+ if (OptRemarkFile)
+ OptRemarkFile->keep();
if (ThinLinkOut)
ThinLinkOut->keep();