Skip to content

[memprof] Use static instead of anonymous namespaces #87889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 12 additions & 20 deletions llvm/lib/ProfileData/MemProf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

namespace llvm {
namespace memprof {
namespace {
size_t serializedSizeV0(const IndexedAllocationInfo &IAI) {
static size_t serializedSizeV0(const IndexedAllocationInfo &IAI) {
size_t Size = 0;
// The number of frames to serialize.
Size += sizeof(uint64_t);
Expand All @@ -22,15 +21,14 @@ size_t serializedSizeV0(const IndexedAllocationInfo &IAI) {
return Size;
}

size_t serializedSizeV2(const IndexedAllocationInfo &IAI) {
static size_t serializedSizeV2(const IndexedAllocationInfo &IAI) {
size_t Size = 0;
// The CallStackId
Size += sizeof(CallStackId);
// The size of the payload.
Size += PortableMemInfoBlock::serializedSize();
return Size;
}
} // namespace

size_t IndexedAllocationInfo::serializedSize(IndexedVersion Version) const {
switch (Version) {
Expand All @@ -43,8 +41,7 @@ size_t IndexedAllocationInfo::serializedSize(IndexedVersion Version) const {
llvm_unreachable("unsupported MemProf version");
}

namespace {
size_t serializedSizeV0(const IndexedMemProfRecord &Record) {
static size_t serializedSizeV0(const IndexedMemProfRecord &Record) {
size_t Result = sizeof(GlobalValue::GUID);
for (const IndexedAllocationInfo &N : Record.AllocSites)
Result += N.serializedSize(Version0);
Expand All @@ -59,7 +56,7 @@ size_t serializedSizeV0(const IndexedMemProfRecord &Record) {
return Result;
}

size_t serializedSizeV2(const IndexedMemProfRecord &Record) {
static size_t serializedSizeV2(const IndexedMemProfRecord &Record) {
size_t Result = sizeof(GlobalValue::GUID);
for (const IndexedAllocationInfo &N : Record.AllocSites)
Result += N.serializedSize(Version2);
Expand All @@ -70,7 +67,6 @@ size_t serializedSizeV2(const IndexedMemProfRecord &Record) {
Result += Record.CallSiteIds.size() * sizeof(CallStackId);
return Result;
}
} // namespace

size_t IndexedMemProfRecord::serializedSize(IndexedVersion Version) const {
switch (Version) {
Expand All @@ -83,9 +79,8 @@ size_t IndexedMemProfRecord::serializedSize(IndexedVersion Version) const {
llvm_unreachable("unsupported MemProf version");
}

namespace {
void serializeV0(const IndexedMemProfRecord &Record,
const MemProfSchema &Schema, raw_ostream &OS) {
static void serializeV0(const IndexedMemProfRecord &Record,
const MemProfSchema &Schema, raw_ostream &OS) {
using namespace support;

endian::Writer LE(OS, llvm::endianness::little);
Expand All @@ -107,8 +102,8 @@ void serializeV0(const IndexedMemProfRecord &Record,
}
}

void serializeV2(const IndexedMemProfRecord &Record,
const MemProfSchema &Schema, raw_ostream &OS) {
static void serializeV2(const IndexedMemProfRecord &Record,
const MemProfSchema &Schema, raw_ostream &OS) {
using namespace support;

endian::Writer LE(OS, llvm::endianness::little);
Expand All @@ -124,7 +119,6 @@ void serializeV2(const IndexedMemProfRecord &Record,
for (const auto &CSId : Record.CallSiteIds)
LE.write<CallStackId>(CSId);
}
} // namespace

void IndexedMemProfRecord::serialize(const MemProfSchema &Schema,
raw_ostream &OS, IndexedVersion Version) {
Expand All @@ -140,9 +134,8 @@ void IndexedMemProfRecord::serialize(const MemProfSchema &Schema,
llvm_unreachable("unsupported MemProf version");
}

namespace {
IndexedMemProfRecord deserializeV0(const MemProfSchema &Schema,
const unsigned char *Ptr) {
static IndexedMemProfRecord deserializeV0(const MemProfSchema &Schema,
const unsigned char *Ptr) {
using namespace support;

IndexedMemProfRecord Record;
Expand Down Expand Up @@ -185,8 +178,8 @@ IndexedMemProfRecord deserializeV0(const MemProfSchema &Schema,
return Record;
}

IndexedMemProfRecord deserializeV2(const MemProfSchema &Schema,
const unsigned char *Ptr) {
static IndexedMemProfRecord deserializeV2(const MemProfSchema &Schema,
const unsigned char *Ptr) {
using namespace support;

IndexedMemProfRecord Record;
Expand Down Expand Up @@ -214,7 +207,6 @@ IndexedMemProfRecord deserializeV2(const MemProfSchema &Schema,

return Record;
}
} // namespace

IndexedMemProfRecord
IndexedMemProfRecord::deserialize(const MemProfSchema &Schema,
Expand Down