llvm.org GIT mirror llvm / 9c7400c
[lib/LTO] Initial support for optimization remarks in the new API. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294882 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 3 years ago
4 changed file(s) with 52 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
6666
6767 /// Sample PGO profile path.
6868 std::string SampleProfile;
69
70 /// Optimization remarks file path.
71 std::string RemarksFilename = "";
72
73 /// Whether to emit optimization remarks with hotness informations.
74 bool RemarksWithHotness = false;
6975
7076 bool ShouldDiscardValueNames = true;
7177 DiagnosticHandlerFunction DiagHandler;
365365
366366 handleAsmUndefinedRefs(*Mod, *TM);
367367
368 // Setup optimization remarks.
369 auto DiagFileOrErr = lto::setupOptimizationRemarks(
370 Mod->getContext(), C.RemarksFilename, C.RemarksWithHotness);
371 if (!DiagFileOrErr)
372 return DiagFileOrErr.takeError();
373
368374 if (!C.CodeGenOnly)
369375 if (!opt(C, TM.get(), 0, *Mod, /*IsThinLTO=*/false, CombinedIndex))
370376 return Error::success();
0 ; RUN: llvm-as < %s >%t.bc
1
2 ; RUN: rm -f %t.yaml
3 ; RUN: llvm-lto2 -pass-remarks-output=%t.yaml \
4 ; RUN: -r %t.bc,tinkywinky,p \
5 ; RUN: -r %t.bc,patatino,px \
6 ; RUN: -r %t.bc,main,px -o %t.o %t.bc 2>&1
7 ; RUN: cat %t.yaml | FileCheck %s -check-prefix=YAML
8
9 ; YAML: --- !Passed
10 ; YAML-NEXT: Pass: inline
11 ; YAML-NEXT: Name: Inlined
12 ; YAML-NEXT: Function: main
13 ; YAML-NEXT: Args:
14 ; YAML-NEXT: - Callee: tinkywinky
15 ; YAML-NEXT: - String: ' inlined into '
16 ; YAML-NEXT: - Caller: main
17 ; YAML-NEXT: ...
18
19 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
20 target triple = "x86_64-scei-ps4"
21
22 declare i32 @patatino()
23
24 define i32 @tinkywinky() {
25 %a = call i32 @patatino()
26 ret i32 %a
27 }
28
29 define i32 @main() {
30 %i = call i32 @tinkywinky()
31 ret i32 %i
32 }
8888 "default-triple",
8989 cl::desc(
9090 "Replace unspecified target triples in input files with this triple"));
91
92 static cl::opt
93 OptRemarksOutput("pass-remarks-output",
94 cl::desc("YAML output file for optimization remarks"));
9195
9296 static void check(Error E, std::string Msg) {
9397 if (!E)
175179 check(Conf.addSaveTemps(OutputFilename + "."),
176180 "Config::addSaveTemps failed");
177181
182 // Optimization remarks.
183 Conf.RemarksFilename = OptRemarksOutput;
184
178185 // Run a custom pipeline, if asked for.
179186 Conf.OptPipeline = OptPipeline;
180187 Conf.AAPipeline = AAPipeline;