[PATCH] D36906: Keep Optimization Remark Yaml in NewPM
Sam Elliott via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 18 17:21:47 PDT 2017
lenary created this revision.
Herald added a subscriber: fhahn.
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
https://reviews.llvm.org/D36906
Files:
test/Transforms/Util/libcalls-opt-remarks.ll
tools/opt/NewPMDriver.cpp
tools/opt/NewPMDriver.h
tools/opt/opt.cpp
Index: tools/opt/opt.cpp
===================================================================
--- tools/opt/opt.cpp
+++ tools/opt/opt.cpp
@@ -540,7 +540,8 @@
// 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,
+ YamlFile.get(), PassPipeline, OK, VK,
+ PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex,
EmitModuleHash)
? 0
Index: tools/opt/NewPMDriver.h
===================================================================
--- tools/opt/NewPMDriver.h
+++ tools/opt/NewPMDriver.h
@@ -53,8 +53,8 @@
/// 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 *YamlFile, StringRef PassPipeline,
+ opt_tool::OutputKind OK, opt_tool::VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
bool EmitSummaryIndex, bool EmitModuleHash);
Index: tools/opt/NewPMDriver.cpp
===================================================================
--- tools/opt/NewPMDriver.cpp
+++ tools/opt/NewPMDriver.cpp
@@ -170,8 +170,8 @@
bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
tool_output_file *Out,
tool_output_file *ThinLTOLinkOut,
- StringRef PassPipeline, OutputKind OK,
- VerifierKind VK,
+ tool_output_file *YamlFile, StringRef PassPipeline,
+ OutputKind OK, VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
bool EmitSummaryIndex, bool EmitModuleHash) {
@@ -266,5 +266,9 @@
if (OK == OK_OutputThinLTOBitcode && ThinLTOLinkOut)
ThinLTOLinkOut->keep();
}
+
+ if (YamlFile)
+ YamlFile->keep();
+
return true;
}
Index: test/Transforms/Util/libcalls-opt-remarks.ll
===================================================================
--- test/Transforms/Util/libcalls-opt-remarks.ll
+++ test/Transforms/Util/libcalls-opt-remarks.ll
@@ -1,8 +1,9 @@
-; RUN: opt < %s -instcombine -o /dev/null -pass-remarks-output=%t -S -pass-remarks=instcombine \
-; RUN: 2>&1 | FileCheck %s
+; RUN: opt < %s -instcombine -o /dev/null -pass-remarks-output=%t -S \
+; RUN: -pass-remarks=instcombine 2>&1 | FileCheck %s
+; RUN: cat %t | FileCheck -check-prefix=YAML %s
+; RUN: opt < %s -passes='require<opt-remark-emit>,instcombine' -o /dev/null \
+; RUN: -pass-remarks-output=%t -S -pass-remarks=instcombine 2>&1 | FileCheck %s
; RUN: cat %t | FileCheck -check-prefix=YAML %s
-; RUN: opt < %s -passes='require<opt-remark-emit>,instcombine' -o /dev/null -S -pass-remarks=instcombine \
-; RUN: 2>&1 | FileCheck %s
; CHECK: remark: libcalls-opt-remarks.c:10:10: folded strlen(select) to select of constants{{$}}
; CHECK-NOT: remark:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36906.111775.patch
Type: text/x-patch
Size: 3501 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170819/d1650e45/attachment.bin>
More information about the llvm-commits
mailing list