Index: include/llvm/IR/Attributes.td =================================================================== --- include/llvm/IR/Attributes.td +++ include/llvm/IR/Attributes.td @@ -185,6 +185,7 @@ def NoNansFPMath : StrBoolAttr<"no-nans-fp-math">; def UnsafeFPMath : StrBoolAttr<"unsafe-fp-math">; def NoJumpTables : StrBoolAttr<"no-jump-tables">; +def AccurateSampleProfile : StrBoolAttr<"accurate-sample-profile">; class CompatRule { // The name of the function called to check the attribute of the caller and @@ -216,6 +217,7 @@ def : MergeRule<"setAND">; def : MergeRule<"setOR">; def : MergeRule<"setOR">; +def : MergeRule<"setOR">; def : MergeRule<"adjustCallerSSPLevel">; def : MergeRule<"adjustCallerStackProbes">; def : MergeRule<"adjustCallerStackProbeSize">; Index: lib/Analysis/ProfileSummaryInfo.cpp =================================================================== --- lib/Analysis/ProfileSummaryInfo.cpp +++ lib/Analysis/ProfileSummaryInfo.cpp @@ -39,11 +39,6 @@ cl::desc("A count is cold if it is below the minimum count" " to reach this percentile of total counts.")); -static cl::opt AccurateSampleProfile( - "accurate-sample-profile", cl::Hidden, cl::init(false), - cl::desc("If the sample profile is accurate, we will mark all un-sampled " - "callsite as cold. Otherwise, treat un-sampled callsites as if " - "we have no profile.")); static cl::opt ProfileSummaryHugeWorkingSetSizeThreshold( "profile-summary-huge-working-set-size-threshold", cl::Hidden, cl::init(15000), cl::ZeroOrMore, @@ -231,7 +226,8 @@ // If there is no profile for the caller, and we know the profile is // accurate, we consider the callsite as cold. return (hasSampleProfile() && - (CS.getCaller()->getEntryCount() || AccurateSampleProfile)); + (CS.getCaller()->getEntryCount() || + CS.getCaller()->hasFnAttribute("accurate-sample-profile"))); } INITIALIZE_PASS(ProfileSummaryInfoWrapperPass, "profile-summary-info", Index: test/Transforms/Inline/inline-cold-callsite-samplepgo.ll =================================================================== --- test/Transforms/Inline/inline-cold-callsite-samplepgo.ll +++ test/Transforms/Inline/inline-cold-callsite-samplepgo.ll @@ -2,7 +2,6 @@ ; 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 -accurate-sample-profile | FileCheck %s --check-prefix=ACCURATE define i32 @callee(i32 %x) { %x1 = add i32 %x, 1 @@ -14,14 +13,23 @@ } define i32 @caller(i32 %y1) { +; CHECK-LABEL: @caller ; 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) ret i32 %y2 } declare void @extern() +attributes #0 = { "accurate-sample-profile" } + !llvm.module.flags = !{!1} !1 = !{i32 1, !"ProfileSummary", !2} !2 = !{!3, !4, !5, !6, !7, !8, !9, !10}