[AArch64] [Windows] Use COFF stubs for calls to extern_weak functions
authorMartin Storsjö <martin@martin.st>
Thu, 19 Dec 2019 12:00:44 +0000 (14:00 +0200)
committerMartin Storsjö <martin@martin.st>
Mon, 23 Dec 2019 10:13:49 +0000 (12:13 +0200)
commit5a751e747dbf2c267e944aa961e21de7a815e7eb
tree70b2949c61174ec9ca34e943a5cbd319dafd3346
parentb774aa1011a031b225624277178382bb2db7e26a
[AArch64] [Windows] Use COFF stubs for calls to extern_weak functions

As the extern_weak target might be missing, resolving to the absolute
address zero, we can't use the normal direct PC-relative branch
instructions (as that would result in relocations out of range).

Improve the classifyGlobalFunctionReference method to set
MO_DLLIMPORT/MO_COFFSTUB, and simplify the existing code in
AArch64TargetLowering::LowerCall to use the return value from
classifyGlobalFunctionReference for these cases.

Add code in both AArch64FastISel and GlobalISel/IRTranslator to
bail out for function calls to extern weak functions on windows,
to let SelectionDAG handle them.

This matches what was done for X86 in 6bf108d77a3c.

Differential Revision: https://reviews.llvm.org/D71721
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/Target/AArch64/AArch64FastISel.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call-weak.ll [new file with mode: 0644]
llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
llvm/test/CodeGen/AArch64/windows-extern-weak.ll [new file with mode: 0644]