[llvm] [AArch64] Fix extern_weak function calls on Windows (PR #219202)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 27 05:56:33 PDT 2026
================
@@ -11,7 +11,7 @@ define void @func() nounwind {
; CHECK-NEXT: ldr x8, [x8, :lo12:.refptr.weakfunc]
; CHECK-NEXT: cbz x8, .LBB0_2
; CHECK-NEXT: // %bb.1:
-; CHECK-NEXT: blr x8
+; CHECK-NEXT: bl weakfunc
----------------
mstorsjo wrote:
This is wrong. The previous indirection through a `.refptr` is essential here.
If we have an extern weak, there's a chance that this resolves to absolute null, if there's no actual definition of the symbol. A `bl` instruction encodes a PC relative offset. If the target symbol is absolute null, this doesn't work.
So the existing case, of loading the pointer through `.refptr`, is correct in general.
If the symbol is marked `dso_local` then there's no `.refptr` generated. Only then we may be able to deduce that the symbol won't resolve to absolute null, and the `.refptr` indirection isn't needed. But for the existin cases where `.refptr` is used, we must not change the generated code.
https://github.com/llvm/llvm-project/pull/219202
More information about the llvm-commits
mailing list