llvm-6502/test/CodeGen/AArch64/extern-weak.ll
Tim Northover 8a06229c89 Implement external weak (ELF) symbols on AArch64
Weakly defined symbols should evaluate to 0 if they're undefined at
link-time. This is impossible to do with the usual address generation
patterns, so we should use a literal pool entry to materlialise the
address.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174518 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-06 16:43:33 +00:00

14 lines
360 B
LLVM

; RUN: llc -mtriple=aarch64-none-linux-gnu -o - < %s | FileCheck %s
declare extern_weak i32 @var()
define i32()* @foo() {
; The usual ADRP/ADD pair can't be used for a weak reference because it must
; evaluate to 0 if the symbol is undefined. We use a litpool entry.
ret i32()* @var
; CHECK: ldr x0, .LCPI0_0
; CHECK: .LCPI0_0:
; CHECK-NEXT: .xword var
}