Skip to content

Commit

Permalink
[memprof] Update the isRuntime symbolization check.
Browse files Browse the repository at this point in the history
Update the isRuntime check to only match against known memprof filenames
where interceptors are defined. This avoid issues where the path does
not include the directory based on how the runtime was compiled. Also
update the unittest.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D145521
  • Loading branch information
snehasish committed Mar 7, 2023
1 parent a90a7b0 commit bcebade
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 6 additions & 2 deletions llvm/lib/ProfileData/RawMemProfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,12 @@ Error report(Error E, const StringRef Context) {
}

bool isRuntimePath(const StringRef Path) {
return StringRef(llvm::sys::path::convert_to_slash(Path))
.contains("memprof/memprof_");
const StringRef Filename = llvm::sys::path::filename(Path);
// This list should be updated in case new files with additional interceptors
// are added to the memprof runtime.
return Filename.equals("memprof_malloc_linux.cpp") ||
Filename.equals("memprof_interceptors.cpp") ||
Filename.equals("memprof_new_delete.cpp");
}

std::string getBuildIdString(const SegmentEntry &Entry) {
Expand Down
13 changes: 11 additions & 2 deletions llvm/unittests/ProfileData/MemProfTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,23 @@ TEST(MemProf, SymbolizationFilter) {
specifier(), false))
.Times(1)
.WillRepeatedly(Return(makeInliningInfo({
{"foo", 10, 5, 30},
{"foo", 10, 5, 30, "memprof/memprof_test_file.cpp"},
})));

EXPECT_CALL(*Symbolizer, symbolizeInlinedCode(SectionedAddress{0x5000},
specifier(), false))
.Times(1)
.WillRepeatedly(Return(makeInliningInfo({
// Depending on how the runtime was compiled, only the filename
// may be present in the debug information.
{"malloc", 70, 57, 3, "memprof_malloc_linux.cpp"},
})));

CallStackMap CSM;
CSM[0x1] = {0x1000, 0x2000, 0x3000, 0x4000};
// This entry should be dropped since all PCs are either not
// symbolizable or belong to the runtime.
CSM[0x2] = {0x1000, 0x2000};
CSM[0x2] = {0x1000, 0x2000, 0x5000};

llvm::MapVector<uint64_t, MemInfoBlock> Prof;
Prof[0x1].AllocCount = 1;
Expand Down

0 comments on commit bcebade

Please sign in to comment.