Skip to content

Commit 47669af

Browse files
authored
[llvm-profgen] Ignore inline frames with an emtpy function name (llvm#66678)
Broken debug information can give empty names for an inlined frame, e.g, ``` 0x1d605c68: ryKeyINS7_17SmartCounterTypesEEESt10shared_ptrINS7_15AsyncCacheValueIS9_EEESaIhESt6atomicEEE9fetch_subElSt12memory_order at Filename: edata.h Function start filename: edata.h Function start line: 266 Function start address: 0x1d605c68 Line: 267 Column: 0 (inlined by) at Filename: edata.h Function start filename: edata.h Function start line: 274 Function start address: 0x1d605c68 Line: 275 Column: 0 (inlined by) _EEEmmEv at Filename: arena.c Function start filename: arena.c Function start line: 1303 Line: 1308 Column: 0 ``` This patch avoids creating a sample context with an empty function name by stopping tracking at that frame. This prevents a hash failure that leads to an ICE, where empty context serves at an empty key for the underlying MapVector https://github.com/llvm/llvm-project/blob/7624de5beae2f142abfdb3e32a63c263a586d768/llvm/lib/ProfileData/SampleProfWriter.cpp#L261
1 parent 61d361d commit 47669af

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

llvm/include/llvm/ProfileData/SampleProf.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,9 @@ class SampleContext {
533533
SampleContext() : State(UnknownContext), Attributes(ContextNone) {}
534534

535535
SampleContext(StringRef Name)
536-
: Name(Name), State(UnknownContext), Attributes(ContextNone) {}
536+
: Name(Name), State(UnknownContext), Attributes(ContextNone) {
537+
assert(!Name.empty() && "Name is empty");
538+
}
537539

538540
SampleContext(SampleContextFrames Context,
539541
ContextStateMask CState = RawContext)

llvm/tools/llvm-profgen/ProfiledBinary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ SampleContextFrameVector ProfiledBinary::symbolize(const InstructionPointer &IP,
865865
SampleContextFrameVector CallStack;
866866
for (int32_t I = InlineStack.getNumberOfFrames() - 1; I >= 0; I--) {
867867
const auto &CallerFrame = InlineStack.getFrame(I);
868-
if (CallerFrame.FunctionName == "<invalid>")
868+
if (CallerFrame.FunctionName.empty() || (CallerFrame.FunctionName == "<invalid>"))
869869
break;
870870

871871
StringRef FunctionName(CallerFrame.FunctionName);

0 commit comments

Comments
 (0)