[llvm] [PGO]add bitcode-use-sample-profile (PR #66178)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 13 00:20:48 PDT 2023
https://github.com/lifengxiang1025 created https://github.com/llvm/llvm-project/pull/66178:
When use bitcode file as input and use "-fprofile-sample-use" first. Function don't has "use-sample-profile" attribute and then "buildFunctionOrder" return empty vector.
when "bitcode-use-sample-profile" enable, add "use-sample-profile" to function and make it can do optimation about pgo.
>From 1963ea19a4eea869798736adeb1abfe2eeaae1c9 Mon Sep 17 00:00:00 2001
From: Fengxiang Li <lifengxiang.1025 at bytedance.com>
Date: Wed, 13 Sep 2023 14:52:50 +0800
Subject: [PATCH] add bitcode-use-sample-profile for using bitcode file as
input with profile-sample-use
---
llvm/lib/Transforms/IPO/SampleProfile.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 67a2e167b6bf7dd..77fe2fa5c358940 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -314,6 +314,11 @@ static cl::opt<bool> AnnotateSampleProfileInlinePhase(
cl::desc("Annotate LTO phase (prelink / postlink), or main (no LTO) for "
"sample-profile inline pass name."));
+static cl::opt<bool>
+ BitCodeUseSampleProfile("bitcode-use-sample-profile", cl::Hidden,
+ cl::init(false),
+ cl::desc("Bitcode file uses sampling profile"));
+
namespace llvm {
extern cl::opt<bool> EnableExtTspBlockPlacement;
}
@@ -1886,6 +1891,10 @@ SampleProfileLoader::buildFunctionOrder(Module &M, LazyCallGraph &CG) {
errs() << "WARNING: -use-profiled-call-graph ignored, should be used "
"together with -sample-profile-top-down-load.\n";
+ for (Function &F : M)
+ if (!F.isDeclaration() && BitCodeUseSampleProfile)
+ F.addFnAttr("use-sample-profile");
+
if (!ProfileTopDownLoad) {
if (ProfileMergeInlinee) {
// Disable ProfileMergeInlinee if profile is not loaded in top down order,
More information about the llvm-commits
mailing list