[llvm] [win][arm64ec] Handle `available_externally` functions (PR #151610)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 31 16:00:22 PDT 2025


================
@@ -872,7 +872,7 @@ bool AArch64Arm64ECCallLowering::runOnModule(Module &Mod) {
     if (!F.isDeclaration() && (!F.hasLocalLinkage() || F.hasAddressTaken()) &&
         F.getCallingConv() != CallingConv::ARM64EC_Thunk_Native &&
         F.getCallingConv() != CallingConv::ARM64EC_Thunk_X64) {
-      if (!F.hasComdat())
+      if (!F.hasComdat() && !F.isDeclarationForLinker())
         F.setComdat(Mod.getOrInsertComdat(F.getName()));
----------------
efriedma-quic wrote:

We also want to skip creating an entry thunk for an available_externally function.  The thunk should be provided by the translation unit that actually defines the function, and emitting an extra one could cause weird linker behavior.

We still may need a exit thunk, if the function is called.

I'd like to see the test show that we don't create an entry thunk, and do create an exit thunk.

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


More information about the llvm-commits mailing list