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 | 802d420792769f789f372748a739aa10feccbb26 (patch) | |
tree | fc8945dcd625ffc798331eda3e796ce4332509e0 /test/CodeGen/ARM/tail-call.ll | |
parent | 9735ccb7ead8598fded49a5ce2f0caf978afcccd (diff) |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215890 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/ARM/tail-call.ll')
-rw-r--r-- | test/CodeGen/ARM/tail-call.ll | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/CodeGen/ARM/tail-call.ll b/test/CodeGen/ARM/tail-call.ll index 771158632ec..c3e79652c03 100644 --- a/test/CodeGen/ARM/tail-call.ll +++ b/test/CodeGen/ARM/tail-call.ll @@ -3,6 +3,7 @@ ; RUN: | FileCheck %s -check-prefix CHECK-NO-TAIL declare i32 @callee(i32 %i) +declare extern_weak fastcc void @callee_weak() define i32 @caller(i32 %i) { entry: @@ -19,3 +20,12 @@ entry: ; CHECK-NO-TAIL: pop {lr} ; CHECK-NO-TAIL: bx lr + +; 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 +} |