diff options
author | Oliver Stannard <oliver.stannard@arm.com> | 2014-08-18 12:42:15 +0000 |
---|---|---|
committer | Oliver Stannard <oliver.stannard@arm.com> | 2014-08-18 12:42:15 +0000 |
commit | 12993dd916d4b1bbe7eb60e4a4b031f3dc760424 (patch) | |
tree | 832fa7be8ff625b9b5852b69c34297b5d19c9a0a /llvm/test/CodeGen/AArch64/tail-call.ll | |
parent | 34d2d76d25f39a07b34b0c66f9a8a1d5174640c7 (diff) | |
download | bcm5719-llvm-12993dd916d4b1bbe7eb60e4a4b031f3dc760424.tar.gz bcm5719-llvm-12993dd916d4b1bbe7eb60e4a4b031f3dc760424.zip |
[ARM,AArch64] Do not tail-call to an externally-defined function with weak linkage
Externally-defined functions with weak linkage should not be
tail-called on ARM or AArch64, as the AAELF spec requires normal calls
to undefined weak functions to be replaced with a NOP or jump to the
next instruction. The behaviour of branch instructions in this
situation (as used for tail calls) is implementation-defined, so we
cannot rely on the linker replacing the tail call with a return.
llvm-svn: 215890
Diffstat (limited to 'llvm/test/CodeGen/AArch64/tail-call.ll')
-rw-r--r-- | llvm/test/CodeGen/AArch64/tail-call.ll | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/AArch64/tail-call.ll b/llvm/test/CodeGen/AArch64/tail-call.ll index 8aab8421526..7fb39545a32 100644 --- a/llvm/test/CodeGen/AArch64/tail-call.ll +++ b/llvm/test/CodeGen/AArch64/tail-call.ll @@ -3,6 +3,7 @@ declare fastcc void @callee_stack0() declare fastcc void @callee_stack8([8 x i32], i64) declare fastcc void @callee_stack16([8 x i32], i64, i64) +declare extern_weak fastcc void @callee_weak() define fastcc void @caller_to0_from0() nounwind { ; CHECK-LABEL: caller_to0_from0: @@ -92,3 +93,13 @@ define fastcc void @caller_to16_from16([8 x i32], i64 %a, i64 %b) { ; CHECK-NEXT: add sp, sp, #16 ; CHECK-NEXT: b callee_stack16 } + + +; Weakly-referenced extern functions cannot be tail-called, as AAELF does +; not define the behaviour of branch instructions to undefined weak symbols. +define fastcc void @caller_weak() { +; CHECK-LABEL: caller_weak: +; CHECK: bl callee_weak + tail call void @callee_weak() + ret void +} |