llvm.org GIT mirror llvm / 74a34d9
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 Sam Elliott 2 years ago
11 changed file(s) with 46 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: opt < %s -gvn -o /dev/null -pass-remarks-output=%t -S -pass-remarks=gvn \
1 ; RUN: 2>&1 | FileCheck %s
2 ; RUN: cat %t | FileCheck -check-prefix=YAML %s
3 ; RUN: opt < %s -aa-pipeline=basic-aa -passes=gvn -o /dev/null -pass-remarks-output=%t -S -pass-remarks=gvn \
14 ; RUN: 2>&1 | FileCheck %s
25 ; RUN: cat %t | FileCheck -check-prefix=YAML %s
36
0 ; RUN: opt < %s -loop-vectorize -S -pass-remarks-missed='loop-vectorize' -pass-remarks-analysis='loop-vectorize' 2>&1 | FileCheck %s
11 ; RUN: opt < %s -loop-vectorize -o /dev/null -pass-remarks-output=%t.yaml
2 ; RUN: cat %t.yaml | FileCheck -check-prefix=YAML %s
3
4 ; RUN: opt < %s -passes=loop-vectorize -S -pass-remarks-missed='loop-vectorize' -pass-remarks-analysis='loop-vectorize' 2>&1 | FileCheck %s
5 ; RUN: opt < %s -passes=loop-vectorize -o /dev/null -pass-remarks-output=%t.yaml
26 ; RUN: cat %t.yaml | FileCheck -check-prefix=YAML %s
37
48 ; C/C++ code for tests
11 ; RUN: opt < %s -newgvn -o /dev/null -pass-remarks-output=%t -S -pass-remarks=gvn \
22 ; RUN: 2>&1 | FileCheck %s
33 ; RUN: cat %t | FileCheck -check-prefix=YAML %s
4 ; RUN: opt < %s -passes=newgvn -o /dev/null -pass-remarks-output=%t -S -pass-remarks=gvn \
5 ; RUN: 2>&1 | FileCheck %s
6 ; RUN: cat %t | FileCheck -check-prefix=YAML %s
7
48
59 ; CHECK: remark: :0:0: load of type i32 eliminated{{$}}
610 ; CHECK-NEXT: remark: :0:0: load of type i32 eliminated{{$}}
0 ; RUN: opt < %s -pgo-memop-opt -pgo-memop-count-threshold=90 -pgo-memop-percent-threshold=15 -S | FileCheck %s --check-prefix=MEMOP_OPT
1 ; RUN: opt < %s -passes=pgo-memop-opt -pgo-memop-count-threshold=90 -pgo-memop-percent-threshold=15 -S | FileCheck %s --check-prefix=MEMOP_OPT
12 ; RUN: opt < %s -pgo-memop-opt -pgo-memop-count-threshold=90 -pgo-memop-percent-threshold=15 -pass-remarks-with-hotness -pass-remarks-output=%t.opt.yaml -S | FileCheck %s --check-prefix=MEMOP_OPT
23 ; RUN: FileCheck %s -input-file=%t.opt.yaml --check-prefix=YAML
4 ; RUN: opt < %s -passes=pgo-memop-opt -pgo-memop-count-threshold=90 -pgo-memop-percent-threshold=15 -pass-remarks-with-hotness -pass-remarks-output=%t.opt.yaml -S | FileCheck %s --check-prefix=MEMOP_OPT
5 ; RUN: FileCheck %s -input-file=%t.opt.yaml --check-prefix=YAML
6
37
48 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
59 target triple = "x86_64-unknown-linux-gnu"
0 ; RUN: opt -S -slp-vectorizer -slp-threshold=-18 -dce -instcombine -pass-remarks-output=%t < %s | FileCheck %s
11 ; RUN: cat %t | FileCheck -check-prefix=YAML %s
2 ; RUN: opt -S -passes='slp-vectorizer,dce,instcombine' -slp-threshold=-18 -pass-remarks-output=%t < %s | FileCheck %s
3 ; RUN: cat %t | FileCheck -check-prefix=YAML %s
4
25
36 target datalayout = "e-m:e-i32:64-i128:128-n32:64-S128"
47 target triple = "aarch64--linux-gnu"
0 ; RUN: opt -slp-vectorizer -slp-threshold=-6 -S -pass-remarks-output=%t < %s | FileCheck %s
11 ; RUN: cat %t | FileCheck -check-prefix=YAML %s
2 ; RUN: opt -passes=slp-vectorizer -slp-threshold=-6 -S -pass-remarks-output=%t < %s | FileCheck %s
3 ; RUN: cat %t | FileCheck -check-prefix=YAML %s
4
25
36 ; FIXME: The threshold is changed to keep this test case a bit smaller.
47 ; The AArch64 cost model should not give such high costs to select statements.
0 ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/remarks.prof -S -pass-remarks=sample-profile -pass-remarks-output=%t.opt.yaml 2>&1 | FileCheck %s
1 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/remarks.prof -S -pass-remarks=sample-profile 2>&1 | FileCheck %s
21 ; RUN: FileCheck %s -check-prefix=YAML < %t.opt.yaml
2 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/remarks.prof -S -pass-remarks=sample-profile -pass-remarks-output=%t.opt.yaml 2>&1 | FileCheck %s
3 ; RUN: FileCheck %s -check-prefix=YAML < %t.opt.yaml
4
35 ; Original test case.
46 ;
57 ; 1 #include
None ; RUN: opt < %s -instcombine -o /dev/null -pass-remarks-output=%t -S -pass-remarks=instcombine \
1 ; RUN: 2>&1 | FileCheck %s
0 ; RUN: opt < %s -instcombine -o /dev/null -pass-remarks-output=%t -S \
1 ; RUN: -pass-remarks=instcombine 2>&1 | FileCheck %s
22 ; RUN: cat %t | FileCheck -check-prefix=YAML %s
3 ; RUN: opt < %s -passes='require,instcombine' -o /dev/null -S -pass-remarks=instcombine \
4 ; RUN: 2>&1 | FileCheck %s
3 ; RUN: opt < %s -passes='require,instcombine' -o /dev/null \
4 ; RUN: -pass-remarks-output=%t -S -pass-remarks=instcombine 2>&1 | FileCheck %s
5 ; RUN: cat %t | FileCheck -check-prefix=YAML %s
56
67 ; CHECK: remark: libcalls-opt-remarks.c:10:10: folded strlen(select) to select of constants{{$}}
78 ; CHECK-NOT: remark:
169169 bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
170170 tool_output_file *Out,
171171 tool_output_file *ThinLTOLinkOut,
172 tool_output_file *OptRemarkFile,
172173 StringRef PassPipeline, OutputKind OK,
173174 VerifierKind VK,
174175 bool ShouldPreserveAssemblyUseListOrder,
265266 if (OK == OK_OutputThinLTOBitcode && ThinLTOLinkOut)
266267 ThinLTOLinkOut->keep();
267268 }
269
270 if (OptRemarkFile)
271 OptRemarkFile->keep();
272
268273 return true;
269274 }
5252 /// nullptr.
5353 bool runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
5454 tool_output_file *Out, tool_output_file *ThinLinkOut,
55 StringRef PassPipeline, opt_tool::OutputKind OK,
56 opt_tool::VerifierKind VK,
55 tool_output_file *OptRemarkFile, StringRef PassPipeline,
56 opt_tool::OutputKind OK, opt_tool::VerifierKind VK,
5757 bool ShouldPreserveAssemblyUseListOrder,
5858 bool ShouldPreserveBitcodeUseListOrder,
5959 bool EmitSummaryIndex, bool EmitModuleHash);
429429 if (PassRemarksHotnessThreshold)
430430 Context.setDiagnosticsHotnessThreshold(PassRemarksHotnessThreshold);
431431
432 std::unique_ptr YamlFile;
432 std::unique_ptr OptRemarkFile;
433433 if (RemarksFilename != "") {
434434 std::error_code EC;
435 YamlFile = llvm::make_unique(RemarksFilename, EC,
436 sys::fs::F_None);
435 OptRemarkFile = llvm::make_unique(RemarksFilename, EC,
436 sys::fs::F_None);
437437 if (EC) {
438438 errs() << EC.message() << '\n';
439439 return 1;
440440 }
441441 Context.setDiagnosticsOutputFile(
442 llvm::make_unique(YamlFile->os()));
442 llvm::make_unique(OptRemarkFile->os()));
443443 }
444444
445445 // Load the input module...
539539 // string. Hand off the rest of the functionality to the new code for that
540540 // layer.
541541 return runPassPipeline(argv[0], *M, TM.get(), Out.get(), ThinLinkOut.get(),
542 PassPipeline, OK, VK, PreserveAssemblyUseListOrder,
542 OptRemarkFile.get(), PassPipeline, OK, VK,
543 PreserveAssemblyUseListOrder,
543544 PreserveBitcodeUseListOrder, EmitSummaryIndex,
544545 EmitModuleHash)
545546 ? 0
766767 "the compile-twice option\n";
767768 Out->os() << BOS->str();
768769 Out->keep();
769 if (YamlFile)
770 YamlFile->keep();
770 if (OptRemarkFile)
771 OptRemarkFile->keep();
771772 return 1;
772773 }
773774 Out->os() << BOS->str();
777778 if (!NoOutput || PrintBreakpoints)
778779 Out->keep();
779780
780 if (YamlFile)
781 YamlFile->keep();
781 if (OptRemarkFile)
782 OptRemarkFile->keep();
782783
783784 if (ThinLinkOut)
784785 ThinLinkOut->keep();