For mingw target, if a symbol is not marked DSO local, a `.refptr` is generated for it. This makes CFG check calls use an extra pointer dereference, which adds extra overhead compared to the MSVC version, so mark the CFG guard check funciton pointer DSO local to stop it. This should have no effect on MSVC target. Also adapt the existing cfguard tests to run for mingw targets, so that this change is checked. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D132331
27 lines
723 B
LLVM
27 lines
723 B
LLVM
|
|
; RUN: llc < %s -mtriple=aarch64-pc-windows-msvc | FileCheck %s
|
|
; RUN: llc < %s -mtriple=aarch64-w64-windows-gnu | FileCheck %s
|
|
; Control Flow Guard is currently only available on Windows
|
|
|
|
; Test that Control Flow Guard checks are not added in modules with the
|
|
; cfguard=1 flag (emit tables but no checks).
|
|
|
|
|
|
declare void @target_func()
|
|
|
|
define void @func_in_module_without_cfguard() #0 {
|
|
entry:
|
|
%func_ptr = alloca void ()*, align 8
|
|
store void ()* @target_func, void ()** %func_ptr, align 8
|
|
%0 = load void ()*, void ()** %func_ptr, align 8
|
|
|
|
call void %0()
|
|
ret void
|
|
|
|
; CHECK-NOT: __guard_check_icall_fptr
|
|
; CHECK-NOT: __guard_dispatch_icall_fptr
|
|
}
|
|
|
|
!llvm.module.flags = !{!0}
|
|
!0 = !{i32 2, !"cfguard", i32 1}
|