The existing module symbol mangling scheme turns out to be undemangleable. It is also desirable to switch to the strong-ownership model as the hoped-for C++17 compatibility turns out to be fragile, and we also now have a better way of controlling that.
The issue is captured on the ABI list at: https://github.com/itanium-cxx-abi/cxx-abi/issues/134
A document describing the issues and new mangling is at: https://drive.google.com/file/d/1quPYyByXqOpCyAPlxYt1JleA70TSFMrp/view?usp=sharing
This patch is the code-generation part. I have a demangler too, but that patch is based on some to-be-landed refactoring of the demangler.
The old mangling is unceremoniously dropped. No backwards compatibility, no deprectated old-mangling flag. It was always labelled experimental. (Old and new manglings cannot be confused.)
FWIW I'm fine with waiting until (a) demangler is ready and (b) clang-14 is out (just in case there's more changes needed)
Do we ever call this function on (say) a LinkageSpecDecl or an ExportDecl? (I think the right thing to do would be to skip over ExportDecls and say that a declaration has no owning module for linkage if there's any enclosing LinkageSpecDecl -- I think in C++ terminology, getOwningModule is determining purview and getOwningModuleForLinkage is determining attachment).
Probably this comment is best left for a different patch, though!