[llvm] [clang] [MemProf] Expand optimization scope to internal linakge function (PR #73236)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 23 04:32:50 PST 2023
https://github.com/lifengxiang1025 updated https://github.com/llvm/llvm-project/pull/73236
>From fdce13021329985b7c3cb8748ee4f8f7f83a2730 Mon Sep 17 00:00:00 2001
From: lifengxiang <lifengxiang.1025 at bytedance.com>
Date: Thu, 23 Nov 2023 20:32:25 +0800
Subject: [PATCH] [MemProf] Expand optimization scope to internal linakge
function
---
clang/lib/CodeGen/CGDeclCXX.cpp | 3 +++
.../Transforms/Instrumentation/MemProfiler.cpp | 16 +---------------
2 files changed, 4 insertions(+), 15 deletions(-)
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index e08a1e5f42df20c..ae45c23c9e6811c 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -538,6 +538,9 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D,
{
llvm::raw_svector_ostream Out(FnName);
getCXXABI().getMangleContext().mangleDynamicInitializer(D, Out);
+ if (getCodeGenOpts().UniqueInternalLinkageNames) {
+ Out << getModuleNameHash();
+ }
}
// Create a variable initialization function.
diff --git a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
index c6134ce77136364..97db0122be7c8e7 100644
--- a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
@@ -677,24 +677,10 @@ static void readMemprof(Module &M, Function &F,
const TargetLibraryInfo &TLI) {
auto &Ctx = M.getContext();
- auto FuncName = getIRPGOFuncName(F);
+ auto FuncName = F.getName();
auto FuncGUID = Function::getGUID(FuncName);
std::optional<memprof::MemProfRecord> MemProfRec;
auto Err = MemProfReader->getMemProfRecord(FuncGUID).moveInto(MemProfRec);
- if (Err) {
- // If we don't find getIRPGOFuncName(), try getPGOFuncName() to handle
- // profiles built by older compilers
- Err = handleErrors(std::move(Err), [&](const InstrProfError &IE) -> Error {
- if (IE.get() != instrprof_error::unknown_function)
- return make_error<InstrProfError>(IE);
- auto FuncName = getPGOFuncName(F);
- auto FuncGUID = Function::getGUID(FuncName);
- if (auto Err =
- MemProfReader->getMemProfRecord(FuncGUID).moveInto(MemProfRec))
- return Err;
- return Error::success();
- });
- }
if (Err) {
handleAllErrors(std::move(Err), [&](const InstrProfError &IPE) {
auto Err = IPE.get();
More information about the cfe-commits
mailing list