https://github.com/efriedma-quic commented:

I'm not sure I understand how the choice of mangling is connected to standard 
conformance.

A name is, from a CodeGen perspective, either local (can't be referred to from 
other translation units), or external (can be referred to from other 
translation units).  If a name is local, its mangling doesn't matter: it can't 
be referenced anyway, so nothing can tell if we change the name.

Note that this isn't directly connected to what the C++ standard calls 
"linkage".  Consider:

```c++
inline int f() { static int z; return ++z; }
```

"z" doesn't have linkage, but we still need a standardized mangling for it 
because we emit references to it from multiple translation units.

Given that, I can't see how there's any use to having a mode where we don't 
mangle the module identity into the name of the global.  If the mangled 
identifier needs to refer to the same entity in other object files, it needs 
the module name mangled in so it doesn't conflict.  If it doesn't, the mangled 
name doesn't matter.

(As an exception to the "local names" rule, clang makes some effort to preserve 
internal names of functions marked `__attribute__((used))` so they can be 
referenced by inline asm, but that generally isn't relevant for anything using 
C++ mangling.)

https://github.com/llvm/llvm-project/pull/219238
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to