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
50 lines
1.0 KiB
LLVM
50 lines
1.0 KiB
LLVM
; RUN: opt < %s -passes=partial-inliner -S 2>&1| FileCheck %s
|
|
|
|
define i32 @callee1(i32 %arg) {
|
|
bb:
|
|
%tmp = icmp slt i32 %arg, 0
|
|
br i1 %tmp, label %bb1, label %bb2
|
|
|
|
bb1:
|
|
br i1 undef, label %bb4, label %bb2
|
|
|
|
bb2:
|
|
br i1 undef, label %bb4, label %bb5
|
|
|
|
bb4:
|
|
%xx1 = phi i32 [ 1, %bb1 ], [ 9, %bb2 ]
|
|
%xx2 = phi i32 [ 1, %bb1 ], [ 9, %bb2 ]
|
|
%xx3 = phi i32 [ 1, %bb1 ], [ 9, %bb2 ]
|
|
tail call void (...) @extern() #2
|
|
br label %bb5
|
|
|
|
bb5:
|
|
%tmp6 = phi i32 [ 1, %bb2 ], [ 9, %bb4 ]
|
|
ret i32 %tmp6
|
|
}
|
|
|
|
declare void @extern(...)
|
|
|
|
define i32 @caller1(i32 %arg) {
|
|
bb:
|
|
;; partial inliner inlines callee to caller.
|
|
; CHECK-LABEL: @caller1
|
|
; CHECK: br i1
|
|
; CHECK: br i1
|
|
; CHECK-NOT: call i32 @callee1(
|
|
%tmp = tail call i32 @callee1(i32 %arg)
|
|
ret i32 %tmp
|
|
}
|
|
|
|
define i32 @caller2(i32 %arg) #0 {
|
|
bb:
|
|
;; partial inliner won't inline callee to caller because they have
|
|
;; incompatible attributes.
|
|
; CHECK-LABEL: @caller2
|
|
; CHECK: call i32 @callee1(
|
|
%tmp = tail call i32 @callee1(i32 %arg)
|
|
ret i32 %tmp
|
|
}
|
|
|
|
attributes #0 = { "use-sample-profile" }
|