[llvm] [AArch64] Fix extern_weak function calls on Windows (PR #219202)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 30 13:59:09 PDT 2026


https://github.com/mstorsjo commented:

The end result in the generated code looks reasoanble.

However I'm hesitant about whether the code change itself is the right way to do it. Most of this handling is similar between X86/ARM/AArch64, and I don't think either of the others have such a special case here. And the fact that we previously generated incorrect code means that there's some other part of the AArch64 backend that disregards the returned flags, so we may want to investigate that too.

> This happened because classifyGlobalFunctionReference delegated to ClassifyGlobalReference for Windows, which returned MO_GOT | MO_COFFSTUB for extern_weak symbols.

If we returned `MO_GOT | MO_COFFSTUB`, then we _should_ reference `.refptr.foo` rather than `.foo`. But apparently we don't. Can you pinpoint which part ends up ignoring these flags in this case? I guess there's some part that looks at the `dso_local` flag early, and picks different code generation based on that.

Then again, on X86/ARM, we don't use `.refptr` here. Can you look into what happens on X86/ARM, what corresponding flags get returned there, and what differs in the generic logic in `ClassifyGlobalReference` there that makes it return `MO_COFFSTUB` here but apparently not on X86/ARM? The general direction of the proper fix would be to find the existing cases and tweak it closer to X86/ARM, not add new special case conditions.

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


More information about the llvm-commits mailing list