[llvm] r309456 - [LTO] llvm-lto2: Add option to load sample profile

Tobias Edler von Koch via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 28 16:43:22 PDT 2017


Author: tobiasvk
Date: Fri Jul 28 16:43:22 2017
New Revision: 309456

URL: http://llvm.org/viewvc/llvm-project?rev=309456&view=rev
Log:
[LTO] llvm-lto2: Add option to load sample profile

Summary:
This exposes LTO's Conf.SampleProfile as a command line option
(-lto-sample-profile-file) for testing via the llvm-lto2 utility.

Reviewers: pcc, danielcdh

Subscribers: mehdi_amini, inglorion, llvm-commits

Differential Revision: https://reviews.llvm.org/D36030

Added:
    llvm/trunk/test/LTO/Resolution/X86/Inputs/load-sample-prof.prof
    llvm/trunk/test/LTO/Resolution/X86/load-sample-prof.ll
Modified:
    llvm/trunk/tools/llvm-lto2/llvm-lto2.cpp

Added: llvm/trunk/test/LTO/Resolution/X86/Inputs/load-sample-prof.prof
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LTO/Resolution/X86/Inputs/load-sample-prof.prof?rev=309456&view=auto
==============================================================================
--- llvm/trunk/test/LTO/Resolution/X86/Inputs/load-sample-prof.prof (added)
+++ llvm/trunk/test/LTO/Resolution/X86/Inputs/load-sample-prof.prof Fri Jul 28 16:43:22 2017
@@ -0,0 +1,2 @@
+foo:100:100
+ 1.0: 100 bar:100

Added: llvm/trunk/test/LTO/Resolution/X86/load-sample-prof.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LTO/Resolution/X86/load-sample-prof.ll?rev=309456&view=auto
==============================================================================
--- llvm/trunk/test/LTO/Resolution/X86/load-sample-prof.ll (added)
+++ llvm/trunk/test/LTO/Resolution/X86/load-sample-prof.ll Fri Jul 28 16:43:22 2017
@@ -0,0 +1,37 @@
+; Test that llvm-lto2 handles the -lto-sample-profile-file option
+;
+; RUN: opt -module-summary < %s -o %t.bc
+; RUN: llvm-lto2 run -o %t.out %t.bc -save-temps \
+; RUN:   -r %t.bc,foo,px -r %t.bc,bar,x \
+; RUN:   -lto-sample-profile-file=%S/Inputs/load-sample-prof.prof
+; RUN: llvm-dis %t.out.0.4.opt.bc -o - | FileCheck %s
+;
+; CHECK: !prof
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @foo() local_unnamed_addr !dbg !7 {
+entry:
+  tail call void @bar(), !dbg !10
+  ret void, !dbg !11
+}
+
+declare void @bar() local_unnamed_addr
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "test.c", directory: "/tmp")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 6.0.0 "}
+!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !0, variables: !2)
+!8 = !DISubroutineType(types: !9)
+!9 = !{null}
+!10 = !DILocation(line: 4, column: 5, scope: !7)
+!11 = !DILocation(line: 5, column: 1, scope: !7)

Modified: llvm/trunk/tools/llvm-lto2/llvm-lto2.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-lto2/llvm-lto2.cpp?rev=309456&r1=309455&r2=309456&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-lto2/llvm-lto2.cpp (original)
+++ llvm/trunk/tools/llvm-lto2/llvm-lto2.cpp Fri Jul 28 16:43:22 2017
@@ -100,6 +100,10 @@ static cl::opt<bool> OptRemarksWithHotne
     cl::desc("Whether to include hotness informations in the remarks.\n"
              "Has effect only if -pass-remarks-output is specified."));
 
+static cl::opt<std::string>
+    SamplePGOFile("lto-sample-profile-file",
+                  cl::desc("Specify a SamplePGO profile file"));
+
 static cl::opt<bool>
     UseNewPM("use-new-pm",
              cl::desc("Run LTO passes using the new pass manager"),
@@ -199,6 +203,8 @@ static int run(int argc, char **argv) {
   Conf.RemarksFilename = OptRemarksOutput;
   Conf.RemarksWithHotness = OptRemarksWithHotness;
 
+  Conf.SampleProfile = SamplePGOFile;
+
   // Run a custom pipeline, if asked for.
   Conf.OptPipeline = OptPipeline;
   Conf.AAPipeline = AAPipeline;




More information about the llvm-commits mailing list