This is an archive of the discontinued LLVM Phabricator instance.

[RFC] [C+++20] [Modules] Mangling lambda in modules
AbandonedPublic

Authored by ChuanqiXu on Jan 24 2022, 1:17 AM.

Details

Summary

This tries to solve https://github.com/llvm/llvm-project/issues/52857.

Simply, the key reason is the unnamed class might be externally visible too in c++ modules! It is a little bit surprising to me at the first sight. Since how can an entity without a name to be visible. However, I recognize that it should be so otherwise the optimizer would lose a chance to do IPO (interprocedural optimization, like inlining). The corresponding code would be: https://github.com/llvm/llvm-project/blob/d29e319263de17516f50cd46edbf1e62c1289dd4/clang/lib/AST/Decl.cpp#L1258-L1259.

So I think we didn't met the problem before we introduces C++ modules since we didn't met externally visible unnamed class before.

To my understanding, changing the behavior of mangler is not trivial. It matters to ABI compatibility and other many tools like demangler and debugger. So I marked this one as RFC although it doesn't contain many codes.

Diff Detail

Event Timeline

ChuanqiXu requested review of this revision.Jan 24 2022, 1:17 AM
ChuanqiXu created this revision.

I don't think this is wanted. there are two cases:
a) lambda is attached to some ODR-visible entitity. Something like (in module-purview at namespace-scope) '[maybe-export] auto var = []{};'. Here the lambda acquires 'var' as its context.
b) lambda is not attached like that. p1815 makes it ill-formed for the lambda to be exposed externally in that case.

see https://github.com/itanium-cxx-abi/cxx-abi/issues/84

FWIW I'm redoing the module mangling scheme, the current one is undemangleable

I don't think this is wanted. there are two cases:
a) lambda is attached to some ODR-visible entitity. Something like (in module-purview at namespace-scope) '[maybe-export] auto var = []{};'. Here the lambda acquires 'var' as its context.
b) lambda is not attached like that. p1815 makes it ill-formed for the lambda to be exposed externally in that case.

see https://github.com/itanium-cxx-abi/cxx-abi/issues/84

FWIW I'm redoing the module mangling scheme, the current one is undemangleable

Oh, great to hear you are willing to take this. I know you must know much more about mangling than me. If you are going to refactor the mangling system, this one would be meaning less. I would abandon it later.

BTW, do you mind to be assigned for issue https://github.com/llvm/llvm-project/issues/52857 and https://github.com/llvm/llvm-project/issues/53232?

sure, please reassign them

ChuanqiXu abandoned this revision.Jan 24 2022, 5:59 PM