summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/AArch64/GlobalISel
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2019-12-19 14:00:44 +0200
committerMartin Storsjö <martin@martin.st>2019-12-23 12:13:49 +0200
commit5a751e747dbf2c267e944aa961e21de7a815e7eb (patch)
tree70b2949c61174ec9ca34e943a5cbd319dafd3346 /llvm/test/CodeGen/AArch64/GlobalISel
parentb774aa1011a031b225624277178382bb2db7e26a (diff)
downloadbcm5719-llvm-5a751e747dbf2c267e944aa961e21de7a815e7eb.tar.gz
bcm5719-llvm-5a751e747dbf2c267e944aa961e21de7a815e7eb.zip
[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
Diffstat (limited to 'llvm/test/CodeGen/AArch64/GlobalISel')
-rw-r--r--llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call-weak.ll15
-rw-r--r--llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll17
2 files changed, 15 insertions, 17 deletions
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call-weak.ll b/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call-weak.ll
new file mode 100644
index 00000000000..bea5961efff
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call-weak.ll
@@ -0,0 +1,15 @@
+; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+; RUN: llc %s -stop-after=irtranslator -verify-machineinstrs -mtriple aarch64-apple-darwin -global-isel -o - 2>&1 | FileCheck %s --check-prefixes=DARWIN,COMMON
+
+; Shouldn't tail call when the OS doesn't support it.
+declare extern_weak void @extern_weak_fn()
+define void @test_extern_weak() {
+ ; DARWIN-LABEL: name: test_extern_weak
+ ; DARWIN: bb.1 (%ir-block.0):
+ ; DARWIN: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
+ ; DARWIN: BL @extern_weak_fn, csr_aarch64_aapcs, implicit-def $lr, implicit $sp
+ ; DARWIN: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
+ ; DARWIN: RET_ReallyLR
+ tail call void @extern_weak_fn()
+ ret void
+}
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll b/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
index b49307ca216..174c6ecb899 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
@@ -193,23 +193,6 @@ define void @test_inreg(i8* inreg %ptr) {
ret void
}
-; Shouldn't tail call when the OS doesn't support it. Windows supports this,
-; so we should be able to tail call there.
-declare extern_weak void @extern_weak_fn()
-define void @test_extern_weak() {
- ; DARWIN-LABEL: name: test_extern_weak
- ; DARWIN: bb.1 (%ir-block.0):
- ; DARWIN: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
- ; DARWIN: BL @extern_weak_fn, csr_aarch64_aapcs, implicit-def $lr, implicit $sp
- ; DARWIN: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
- ; DARWIN: RET_ReallyLR
- ; WINDOWS-LABEL: name: test_extern_weak
- ; WINDOWS: bb.1 (%ir-block.0):
- ; WINDOWS: TCRETURNdi @extern_weak_fn, 0, csr_aarch64_aapcs, implicit $sp
- tail call void @extern_weak_fn()
- ret void
-}
-
declare fastcc void @fast_fn()
define void @test_mismatched_caller() {
; COMMON-LABEL: name: test_mismatched_caller
OpenPOWER on IntegriCloud