[PATCH] D136397: [Clang] Change AnonStructIds in MangleContext to per-function based

Rong Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 20 17:14:55 PDT 2022


xur created this revision.
xur added reviewers: rsmith, davidxl.
Herald added a subscriber: wenlei.
Herald added a project: All.
xur requested review of this revision.

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.


https://reviews.llvm.org/D136397

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CodeGen/attr-function-return.cpp
  clang/test/CodeGenCXX/catch-undef-behavior.cpp
  clang/test/CodeGenCXX/cxx1y-init-captures-eh.cpp
  clang/test/CodeGenCXX/cxx1y-init-captures.cpp
  clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
  clang/test/CodeGenCXX/lambda-expressions.cpp
  clang/test/CodeGenCXX/mangle-lambdas.cpp
  clang/test/CodeGenCXX/nrvo.cpp
  clang/test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
  clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
  clang/test/CodeGenObjCXX/lambda-expressions.mm
  clang/test/CodeGenObjCXX/property-lvalue-lambda.mm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136397.469415.patch
Type: text/x-patch
Size: 21193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221021/40ae5730/attachment-0001.bin>


More information about the cfe-commits mailing list