mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
094cf38ca5
Summary: A COFF stub indirects the reference to a symbol through memory. A .refptr.$sym global variable pointer is created to refer to $sym. Typically mingw uses these for external global variable declarations, but we can use them for weak function declarations as well. Updates the dso_local classification to add a special case for extern_weak symbols on COFF in both clang and LLVM. Fixes PR37598 Reviewers: smeenai, mstorsjo Subscribers: hiraditya, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D61615 llvm-svn: 360207
65 lines
1.4 KiB
LLVM
65 lines
1.4 KiB
LLVM
; RUN: llc < %s -mtriple=i686-apple-darwin | FileCheck %s --check-prefix=DARWIN
|
|
; RUN: llc < %s -mtriple=i686-windows-msvc | FileCheck %s --check-prefix=WIN32
|
|
; RUN: llc < %s -mtriple=x86_64-windows-msvc | FileCheck %s --check-prefix=WIN64
|
|
|
|
declare extern_weak void @foo(...)
|
|
|
|
define void @bar() {
|
|
entry:
|
|
br i1 icmp ne (void (...)* @foo, void (...)* null), label %if.then, label %if.end
|
|
|
|
if.then:
|
|
tail call void (...) @foo( )
|
|
ret void
|
|
|
|
if.end:
|
|
ret void
|
|
}
|
|
|
|
; DARWIN-LABEL: _bar:
|
|
; DARWIN: cmpl $0, L_foo$non_lazy_ptr
|
|
; DARWIN: jmp _foo ## TAILCALL
|
|
|
|
; WIN32-LABEL: _bar:
|
|
; WIN32: cmpl $0, .refptr._foo
|
|
; WIN32: jmpl *.refptr._foo
|
|
|
|
; WIN64-LABEL: bar:
|
|
; WIN64: cmpq $0, .refptr.foo(%rip)
|
|
; WIN64: jmpq *.refptr.foo
|
|
|
|
|
|
declare extern_weak i32 @X(i8*)
|
|
|
|
@Y = global i32 (i8*)* @X ; <i32 (i8*)**> [#uses=0]
|
|
|
|
; DARWIN-LABEL: _Y:
|
|
; DARWIN: .long _X
|
|
|
|
; WIN32-LABEL: _Y:
|
|
; WIN32: .long _X
|
|
|
|
; WIN64-LABEL: Y:
|
|
; WIN64: .quad X
|
|
|
|
|
|
; DARWIN: .weak_reference _foo
|
|
; DARWIN: .weak_reference _X
|
|
|
|
; WIN32: .section .rdata$.refptr._foo,"dr",discard,.refptr._foo
|
|
; WIN32: .globl .refptr._foo
|
|
; WIN32: .refptr._foo:
|
|
; WIN32: .long _foo
|
|
|
|
; WIN32: .weak _foo
|
|
; WIN32: .weak _X
|
|
|
|
; WIN64: .section .rdata$.refptr.foo,"dr",discard,.refptr.foo
|
|
; WIN64: .globl .refptr.foo
|
|
; WIN64: .refptr.foo:
|
|
; WIN64: .quad foo
|
|
|
|
; WIN64: .weak foo
|
|
; WIN64: .weak X
|
|
|