1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00
llvm-mirror/test/LTO/Resolution/X86/load-sample-prof-lto.ll
Wei Mi 93d80a543f [SampleFDO] Add use-sample-profile function attribute.
When sampleFDO is enabled, people may expect they can use
-fno-profile-sample-use to opt-out using sample profile for a certain file.
That could be either for debugging purpose or for performance tuning purpose.
However, when thinlto is enabled, if a function in file A compiled with
-fno-profile-sample-use is imported to another file B compiled with
-fprofile-sample-use, the inlined copy of the function in file B may still
get its profile annotated.

The inconsistency may even introduce profile unused warning because if the
target is not compiled with explicit debug information flag, the function
in file A won't have its debug information enabled (debug information will
be enabled implicitly only when -fprofile-sample-use is used). After it is
imported into file B which is compiled with -fprofile-sample-use, profile
annotation for the outline copy of the function will fail because the
function has no debug information, and that will trigger  profile unused
warning.

We add a new attribute use-sample-profile to control whether a function
will use its sample profile no matter for its outline or inline copies.
That will make the behavior of -fno-profile-sample-use consistent.

Differential Revision: https://reviews.llvm.org/D79959
2020-06-02 17:23:17 -07:00

49 lines
1.7 KiB
LLVM

; Test that LTO pipeline loads profile.
;
; RUN: opt < %s -o %t.bc
; Run the old pm LTO pipeline.
; 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
; Run the new pm LTO pipeline.
; RUN: llvm-lto2 run -o %t.out %t.bc -save-temps -use-new-pm \
; 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
; Make sure profile information is attached.
; CHECK: !prof
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define void @foo() #0 !dbg !7 {
entry:
tail call void @bar(), !dbg !10
ret void, !dbg !11
}
declare void @bar() local_unnamed_addr
attributes #0 = {"local_unnamed_addr" "use-sample-profile"}
!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, retainedNodes: !2)
!8 = !DISubroutineType(types: !9)
!9 = !{null}
!10 = !DILocation(line: 4, column: 5, scope: !7)
!11 = !DILocation(line: 5, column: 1, scope: !7)