[llvm] a28261c - [MemProf] Create single version of helper function (NFC)
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Fri May 5 18:31:45 PDT 2023
Author: Teresa Johnson
Date: 2023-05-05T18:31:35-07:00
New Revision: a28261c71166752582417a1b1a2ba427d2371cbe
URL: https://github.com/llvm/llvm-project/commit/a28261c71166752582417a1b1a2ba427d2371cbe
DIFF: https://github.com/llvm/llvm-project/commit/a28261c71166752582417a1b1a2ba427d2371cbe.diff
LOG: [MemProf] Create single version of helper function (NFC)
Small clean up to keep a single version of getAllocTypeAttributeString
which was duplicated locally.
Added:
Modified:
llvm/include/llvm/Analysis/MemoryProfileInfo.h
llvm/lib/Analysis/MemoryProfileInfo.cpp
llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/MemoryProfileInfo.h b/llvm/include/llvm/Analysis/MemoryProfileInfo.h
index bbade1b337916..355bff46f6279 100644
--- a/llvm/include/llvm/Analysis/MemoryProfileInfo.h
+++ b/llvm/include/llvm/Analysis/MemoryProfileInfo.h
@@ -37,6 +37,9 @@ MDNode *getMIBStackNode(const MDNode *MIB);
/// Returns the allocation type from an MIB metadata node.
AllocationType getMIBAllocType(const MDNode *MIB);
+/// Returns the string to use in attributes with the given type.
+std::string getAllocTypeAttributeString(AllocationType Type);
+
/// True if the AllocTypes bitmask contains just a single type.
bool hasSingleAllocType(uint8_t AllocTypes);
diff --git a/llvm/lib/Analysis/MemoryProfileInfo.cpp b/llvm/lib/Analysis/MemoryProfileInfo.cpp
index 366b21be1fbce..d1b62e8170808 100644
--- a/llvm/lib/Analysis/MemoryProfileInfo.cpp
+++ b/llvm/lib/Analysis/MemoryProfileInfo.cpp
@@ -76,7 +76,7 @@ AllocationType llvm::memprof::getMIBAllocType(const MDNode *MIB) {
return AllocationType::NotCold;
}
-static std::string getAllocTypeAttributeString(AllocationType Type) {
+std::string llvm::memprof::getAllocTypeAttributeString(AllocationType Type) {
switch (Type) {
case AllocationType::NotCold:
return "notcold";
diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index 44aea71c31925..7a64397e64c51 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -2231,21 +2231,6 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::identifyClones(
checkNode<DerivedCCG, FuncTy, CallTy>(Node);
}
-static std::string getAllocTypeAttributeString(AllocationType Type) {
- switch (Type) {
- case AllocationType::NotCold:
- return "notcold";
- break;
- case AllocationType::Cold:
- return "cold";
- break;
- default:
- dbgs() << "Unexpected alloc type " << (uint8_t)Type;
- assert(false);
- }
- llvm_unreachable("invalid alloc type");
-}
-
void ModuleCallsiteContextGraph::updateAllocationCall(
CallInfo &Call, AllocationType AllocType) {
std::string AllocTypeString = getAllocTypeAttributeString(AllocType);
More information about the llvm-commits
mailing list