aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorMircea Trofin <mtrofin@google.com>2025-06-25 16:20:10 -0700
committerGitHub <noreply@github.com>2025-06-25 16:20:10 -0700
commit82cbd68504e6206ec40a5b41ea14aa6a4988e6fe (patch)
tree5fef864cbf8b6f63f1e4767b66f39c55803be554 /llvm/lib/IR/Function.cpp
parent00f6d6ab66a7c7caf74562eea442653919a79dd9 (diff)
downloadllvm-82cbd68504e6206ec40a5b41ea14aa6a4988e6fe.zip
llvm-82cbd68504e6206ec40a5b41ea14aa6a4988e6fe.tar.gz
llvm-82cbd68504e6206ec40a5b41ea14aa6a4988e6fe.tar.bz2
[NFC][PGO] Use constants rather than free strings for metadata labels (#145721)
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 28fb810..3e7fcbb 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -37,6 +37,7 @@
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
+#include "llvm/IR/ProfDataUtils.h"
#include "llvm/IR/SymbolTableListTraits.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
@@ -1115,7 +1116,7 @@ std::optional<ProfileCount> Function::getEntryCount(bool AllowSynthetic) const {
MDNode *MD = getMetadata(LLVMContext::MD_prof);
if (MD && MD->getOperand(0))
if (MDString *MDS = dyn_cast<MDString>(MD->getOperand(0))) {
- if (MDS->getString() == "function_entry_count") {
+ if (MDS->getString() == MDProfLabels::FunctionEntryCount) {
ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(1));
uint64_t Count = CI->getValue().getZExtValue();
// A value of -1 is used for SamplePGO when there were no samples.
@@ -1124,7 +1125,8 @@ std::optional<ProfileCount> Function::getEntryCount(bool AllowSynthetic) const {
return std::nullopt;
return ProfileCount(Count, PCT_Real);
} else if (AllowSynthetic &&
- MDS->getString() == "synthetic_function_entry_count") {
+ MDS->getString() ==
+ MDProfLabels::SyntheticFunctionEntryCount) {
ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(1));
uint64_t Count = CI->getValue().getZExtValue();
return ProfileCount(Count, PCT_Synthetic);
@@ -1137,7 +1139,7 @@ DenseSet<GlobalValue::GUID> Function::getImportGUIDs() const {
DenseSet<GlobalValue::GUID> R;
if (MDNode *MD = getMetadata(LLVMContext::MD_prof))
if (MDString *MDS = dyn_cast<MDString>(MD->getOperand(0)))
- if (MDS->getString() == "function_entry_count")
+ if (MDS->getString() == MDProfLabels::FunctionEntryCount)
for (unsigned i = 2; i < MD->getNumOperands(); i++)
R.insert(mdconst::extract<ConstantInt>(MD->getOperand(i))
->getValue()