uraj
uraj

Reputation: 439

C++ function name demangling: What does this name suffix mean?

When I disassemble the Chromium binary I notice there are functions named in this pattern: _ZN6webrtc15DecoderDatabase11DecoderInfoD2Ev.part.1

If I give this string to c++filt, the output is webrtc::DecoderDatabase::DecoderInfo::~DecoderInfo() [clone .part.1]

So what does this .part.1 suffix really mean? If it indicates there are multiple copies of the same function, why do they need that? Is it due to the requirement of being position independent? I used g++ as the compiler.

Upvotes: 5

Views: 627

Answers (1)

Ross Ridge
Ross Ridge

Reputation: 39591

It indicates that destructor was the target of a partial inlining optimization by GCC. With this optimization the function is only partially inlined into another function, the remainder gets emitted into its own partial function. Since this new partial function doesn't implement the complete function it's given a different name, so it can exist beside a definition of the complete function if necessary.

So for example it appears that DecoderDatabase::DecoderInfo::~DecoderInfo is defined like this:

DecoderDatabase::DecoderInfo::~DecoderInfo() {
    if (!external) delete decoder;
}

My guess is that delete decoder invokes a long series of operations, too long to be inlined into another function. The optimizer would accordingly split those operations into a partial function. It would then only inline the if (!external) part of the function into other functions.

Upvotes: 9

Related Questions