2018-03-21 04:37:51 +08:00
|
|
|
; RUN: llc -mtriple=x86_64-w64-mingw32 < %s -o - | FileCheck --check-prefix=MINGW %s
|
|
|
|
; RUN: llc -mtriple=x86_64-pc-windows-itanium < %s -o - | FileCheck --check-prefix=MSVC %s
|
|
|
|
; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s -o - | FileCheck --check-prefix=MSVC %s
|
|
|
|
|
|
|
|
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
|
|
|
|
declare dso_local void @other(i8*)
|
|
|
|
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
|
|
|
|
|
|
|
|
define dso_local void @func() sspstrong {
|
|
|
|
entry:
|
|
|
|
; MINGW-LABEL: func:
|
[MinGW] [X86] Add stubs for references to data variables that might end up imported from a dll
Variables declared with the dllimport attribute are accessed via a
stub variable named __imp_<var>. In MinGW configurations, variables that
aren't declared with a dllimport attribute might still end up imported
from another DLL with runtime pseudo relocs.
For x86_64, this avoids the risk that the target is out of range
for a 32 bit PC relative reference, in case the target DLL is loaded
further than 4 GB from the reference. It also avoids having to make the
text section writable at runtime when doing the runtime fixups, which
makes it worthwhile to do for i386 as well.
Add stub variables for all dso local data references where a definition
of the variable isn't visible within the module, since the DLL data
autoimporting might make them imported even though they are marked as
dso local within LLVM.
Don't do this for variables that actually are defined within the same
module, since we then know for sure that it actually is dso local.
Don't do this for references to functions, since there's no need for
runtime pseudo relocations for autoimporting them; if a function from
a different DLL is called without the appropriate dllimport attribute,
the call just gets routed via a thunk instead.
GCC does something similar since 4.9 (when compiling with -mcmodel=medium
or large; from that version, medium is the default code model for x86_64
mingw), but only for x86_64.
Differential Revision: https://reviews.llvm.org/D51288
llvm-svn: 340942
2018-08-30 01:28:34 +08:00
|
|
|
; MINGW: mov{{l|q}} .refptr.__stack_chk_guard(%rip), [[REG:%[a-z]+]]
|
|
|
|
; MINGW: mov{{l|q}} ([[REG]])
|
2018-03-21 04:37:51 +08:00
|
|
|
; MINGW: callq other
|
[MinGW] [X86] Add stubs for references to data variables that might end up imported from a dll
Variables declared with the dllimport attribute are accessed via a
stub variable named __imp_<var>. In MinGW configurations, variables that
aren't declared with a dllimport attribute might still end up imported
from another DLL with runtime pseudo relocs.
For x86_64, this avoids the risk that the target is out of range
for a 32 bit PC relative reference, in case the target DLL is loaded
further than 4 GB from the reference. It also avoids having to make the
text section writable at runtime when doing the runtime fixups, which
makes it worthwhile to do for i386 as well.
Add stub variables for all dso local data references where a definition
of the variable isn't visible within the module, since the DLL data
autoimporting might make them imported even though they are marked as
dso local within LLVM.
Don't do this for variables that actually are defined within the same
module, since we then know for sure that it actually is dso local.
Don't do this for references to functions, since there's no need for
runtime pseudo relocations for autoimporting them; if a function from
a different DLL is called without the appropriate dllimport attribute,
the call just gets routed via a thunk instead.
GCC does something similar since 4.9 (when compiling with -mcmodel=medium
or large; from that version, medium is the default code model for x86_64
mingw), but only for x86_64.
Differential Revision: https://reviews.llvm.org/D51288
llvm-svn: 340942
2018-08-30 01:28:34 +08:00
|
|
|
; MINGW: mov{{l|q}} ([[REG]])
|
2018-03-21 04:37:51 +08:00
|
|
|
; MINGW: callq __stack_chk_fail
|
|
|
|
; MINGW: .seh_endproc
|
|
|
|
|
|
|
|
; MSVC-LABEL: func:
|
|
|
|
; MSVC: mov{{l|q}} __security_cookie
|
|
|
|
; MSVC: callq other
|
|
|
|
; MSVC: callq __security_check_cookie
|
|
|
|
; MSVC: .seh_endproc
|
|
|
|
|
|
|
|
%c = alloca i8, align 1
|
|
|
|
call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %c)
|
|
|
|
call void @other(i8* nonnull %c)
|
|
|
|
call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull %c)
|
|
|
|
ret void
|
|
|
|
}
|