[clang] [Clang] Allow vanilla C function symbol name to be used in __attribute__((alias)) when -funique-internal-linkage-names is specified (PR #145652)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 25 10:56:36 PDT 2025


================
@@ -4046,6 +4065,12 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
     // The value must be emitted, but cannot be emitted eagerly.
     assert(!MayBeEmittedEagerly(Global));
     addDeferredDeclToEmit(GD);
+  } else if (!getLangOpts().CPlusPlus && ND &&
+             GetGlobalValue(ND->getName()) != nullptr &&
+             MangledName.contains(llvm::FunctionSamples::UniqSuffix)) {
+    // Emit static C function that is mangled with
+    // -funique-internal-linkage-names.
----------------
efriedma-quic wrote:

I'm not really happy with this.  The code for deferred declarations and diagnosing name conflicts is complicated enough without adding the possibility that the name of a declaration can change later.

Can we just suppress mangling in cases where we reference a symbol without knowing if it's internal, then it turns out to be internal later?

https://github.com/llvm/llvm-project/pull/145652


More information about the cfe-commits mailing list