This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Change AnonStructIds in MangleContext to per-function based
ClosedPublic

Authored by xur on Oct 20 2022, 5:14 PM.

Details

Summary

Clang is generating different mangled names for the same lambda function in build that are
slightly different (like from non-related source/Macro change). This is due to the fact that clang uses a
cross-translation-unit sequential string "$_<n>" in lambda's mangled name. Here, "n" is the
AnonStructIds field in MangleContext.

Different mangled names for unchanged function is undesirable: it makes perf comparison harder,
and can cause some unnecessary profile mismatch in SampleFDO.

This patch changes AnonStructIds to a per-function based seq number if the
DeclContext is a function.

I hold the change for Microsoft mangling and only change Itanium mangling.

Diff Detail

Event Timeline

xur created this revision.Oct 20 2022, 5:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 20 2022, 5:14 PM
Herald added a subscriber: wenlei. · View Herald Transcript
xur requested review of this revision.Oct 20 2022, 5:14 PM
rsmith accepted this revision.Oct 20 2022, 7:29 PM

Looks good to me.

clang/include/clang/AST/Mangle.h
97
This revision is now accepted and ready to land.Oct 20 2022, 7:29 PM
xur marked an inline comment as done.Oct 21 2022, 12:00 PM
xur added inline comments.
clang/include/clang/AST/Mangle.h
97

Fixed. Thanks!

This revision was landed with ongoing or failed builds.Oct 23 2022, 10:43 PM
This revision was automatically updated to reflect the committed changes.
xur marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptOct 23 2022, 10:43 PM