mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-11 21:56:15 +00:00
Move accurate-sample-profile into the function attribute.
Summary: We need to have accurate-sample-profile in function attribute so that it works with LTO. Reviewers: davidxl, rsmith Reviewed By: davidxl Subscribers: sanjoy, mehdi_amini, javed.absar, llvm-commits, eraman Differential Revision: https://reviews.llvm.org/D37113 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311706 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2de563a9ab
commit
d38687abb5
@ -185,6 +185,7 @@ def NoInfsFPMath : StrBoolAttr<"no-infs-fp-math">;
|
|||||||
def NoNansFPMath : StrBoolAttr<"no-nans-fp-math">;
|
def NoNansFPMath : StrBoolAttr<"no-nans-fp-math">;
|
||||||
def UnsafeFPMath : StrBoolAttr<"unsafe-fp-math">;
|
def UnsafeFPMath : StrBoolAttr<"unsafe-fp-math">;
|
||||||
def NoJumpTables : StrBoolAttr<"no-jump-tables">;
|
def NoJumpTables : StrBoolAttr<"no-jump-tables">;
|
||||||
|
def ProfileSampleAccurate : StrBoolAttr<"profile-sample-accurate">;
|
||||||
|
|
||||||
class CompatRule<string F> {
|
class CompatRule<string F> {
|
||||||
// The name of the function called to check the attribute of the caller and
|
// The name of the function called to check the attribute of the caller and
|
||||||
@ -216,6 +217,7 @@ def : MergeRule<"setAND<NoNansFPMathAttr>">;
|
|||||||
def : MergeRule<"setAND<UnsafeFPMathAttr>">;
|
def : MergeRule<"setAND<UnsafeFPMathAttr>">;
|
||||||
def : MergeRule<"setOR<NoImplicitFloatAttr>">;
|
def : MergeRule<"setOR<NoImplicitFloatAttr>">;
|
||||||
def : MergeRule<"setOR<NoJumpTablesAttr>">;
|
def : MergeRule<"setOR<NoJumpTablesAttr>">;
|
||||||
|
def : MergeRule<"setOR<ProfileSampleAccurateAttr>">;
|
||||||
def : MergeRule<"adjustCallerSSPLevel">;
|
def : MergeRule<"adjustCallerSSPLevel">;
|
||||||
def : MergeRule<"adjustCallerStackProbes">;
|
def : MergeRule<"adjustCallerStackProbes">;
|
||||||
def : MergeRule<"adjustCallerStackProbeSize">;
|
def : MergeRule<"adjustCallerStackProbeSize">;
|
||||||
|
@ -39,8 +39,8 @@ static cl::opt<int> ProfileSummaryCutoffCold(
|
|||||||
cl::desc("A count is cold if it is below the minimum count"
|
cl::desc("A count is cold if it is below the minimum count"
|
||||||
" to reach this percentile of total counts."));
|
" to reach this percentile of total counts."));
|
||||||
|
|
||||||
static cl::opt<bool> AccurateSampleProfile(
|
static cl::opt<bool> ProfileSampleAccurate(
|
||||||
"accurate-sample-profile", cl::Hidden, cl::init(false),
|
"profile-sample-accurate", cl::Hidden, cl::init(false),
|
||||||
cl::desc("If the sample profile is accurate, we will mark all un-sampled "
|
cl::desc("If the sample profile is accurate, we will mark all un-sampled "
|
||||||
"callsite as cold. Otherwise, treat un-sampled callsites as if "
|
"callsite as cold. Otherwise, treat un-sampled callsites as if "
|
||||||
"we have no profile."));
|
"we have no profile."));
|
||||||
@ -231,7 +231,8 @@ bool ProfileSummaryInfo::isColdCallSite(const CallSite &CS,
|
|||||||
// If there is no profile for the caller, and we know the profile is
|
// If there is no profile for the caller, and we know the profile is
|
||||||
// accurate, we consider the callsite as cold.
|
// accurate, we consider the callsite as cold.
|
||||||
return (hasSampleProfile() &&
|
return (hasSampleProfile() &&
|
||||||
(CS.getCaller()->getEntryCount() || AccurateSampleProfile));
|
(CS.getCaller()->getEntryCount() || ProfileSampleAccurate ||
|
||||||
|
CS.getCaller()->hasFnAttribute("profile-sample-accurate")));
|
||||||
}
|
}
|
||||||
|
|
||||||
INITIALIZE_PASS(ProfileSummaryInfoWrapperPass, "profile-summary-info",
|
INITIALIZE_PASS(ProfileSummaryInfoWrapperPass, "profile-summary-info",
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
; For SamplePGO, if -accurate-sample-profile is specified, cold callsite
|
; For SamplePGO, if -profile-sample-accurate is specified, cold callsite
|
||||||
; heuristics should be honored if the caller has no profile.
|
; heuristics should be honored if the caller has no profile.
|
||||||
|
|
||||||
; RUN: opt < %s -inline -S -inline-cold-callsite-threshold=0 | FileCheck %s
|
; RUN: opt < %s -inline -S -inline-cold-callsite-threshold=0 | FileCheck %s
|
||||||
; RUN: opt < %s -inline -S -inline-cold-callsite-threshold=0 -accurate-sample-profile | FileCheck %s --check-prefix=ACCURATE
|
|
||||||
|
|
||||||
define i32 @callee(i32 %x) {
|
define i32 @callee(i32 %x) {
|
||||||
%x1 = add i32 %x, 1
|
%x1 = add i32 %x, 1
|
||||||
@ -14,14 +13,23 @@ define i32 @callee(i32 %x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
define i32 @caller(i32 %y1) {
|
define i32 @caller(i32 %y1) {
|
||||||
|
; CHECK-LABEL: @caller
|
||||||
; CHECK-NOT: call i32 @callee
|
; CHECK-NOT: call i32 @callee
|
||||||
; ACCURATE: call i32 @callee
|
%y2 = call i32 @callee(i32 %y1)
|
||||||
|
ret i32 %y2
|
||||||
|
}
|
||||||
|
|
||||||
|
define i32 @caller_accurate(i32 %y1) #0 {
|
||||||
|
; CHECK-LABEL: @caller_accurate
|
||||||
|
; CHECK: call i32 @callee
|
||||||
%y2 = call i32 @callee(i32 %y1)
|
%y2 = call i32 @callee(i32 %y1)
|
||||||
ret i32 %y2
|
ret i32 %y2
|
||||||
}
|
}
|
||||||
|
|
||||||
declare void @extern()
|
declare void @extern()
|
||||||
|
|
||||||
|
attributes #0 = { "profile-sample-accurate" }
|
||||||
|
|
||||||
!llvm.module.flags = !{!1}
|
!llvm.module.flags = !{!1}
|
||||||
!1 = !{i32 1, !"ProfileSummary", !2}
|
!1 = !{i32 1, !"ProfileSummary", !2}
|
||||||
!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
|
!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
|
||||||
|
Loading…
Reference in New Issue
Block a user