diff options
Diffstat (limited to 'llvm/test/CodeGen/X86')
| -rw-r--r-- | llvm/test/CodeGen/X86/cfguard-checks.ll | 462 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/cfguard-module-flag.ll | 52 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/cfguard-x86-64-vectorcall.ll | 76 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/cfguard-x86-vectorcall.ll | 86 |
4 files changed, 338 insertions, 338 deletions
diff --git a/llvm/test/CodeGen/X86/cfguard-checks.ll b/llvm/test/CodeGen/X86/cfguard-checks.ll index 5a930afef13..d2cd3c9f3ee 100644 --- a/llvm/test/CodeGen/X86/cfguard-checks.ll +++ b/llvm/test/CodeGen/X86/cfguard-checks.ll @@ -1,231 +1,231 @@ -; RUN: llc < %s -mtriple=i686-pc-windows-msvc | FileCheck %s -check-prefix=X32
-; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s -check-prefix=X64
-; Control Flow Guard is currently only available on Windows
-
-; Test that Control Flow Guard checks are correctly added when required.
-
-
-declare i32 @target_func()
-
-
-; Test that Control Flow Guard checks are not added to functions with nocf_checks attribute.
-define i32 @func_nocf_checks() #0 {
-entry:
- %func_ptr = alloca i32 ()*, align 8
- store i32 ()* @target_func, i32 ()** %func_ptr, align 8
- %0 = load i32 ()*, i32 ()** %func_ptr, align 8
- %1 = call i32 %0()
- ret i32 %1
-
- ; X32-LABEL: func_nocf_checks
- ; X32: movl $_target_func, %eax
- ; X32-NOT: __guard_check_icall_fptr
- ; X32: calll *%eax
-
- ; X64-LABEL: func_nocf_checks
- ; X64: leaq target_func(%rip), %rax
- ; X64-NOT: __guard_dispatch_icall_fptr
- ; X64: callq *%rax
-}
-attributes #0 = { nocf_check }
-
-
-; Test that Control Flow Guard checks are added even at -O0.
-; FIXME Ideally these checks should be added as a single call instruction, as in the optimized case.
-define i32 @func_optnone_cf() #1 {
-entry:
- %func_ptr = alloca i32 ()*, align 8
- store i32 ()* @target_func, i32 ()** %func_ptr, align 8
- %0 = load i32 ()*, i32 ()** %func_ptr, align 8
- %1 = call i32 %0()
- ret i32 %1
-
- ; On i686, the call to __guard_check_icall_fptr should come immediately before the call to the target function.
- ; X32-LABEL: func_optnone_cf
- ; X32: leal _target_func, %eax
- ; X32: movl %eax, (%esp)
- ; X32: movl (%esp), %ecx
- ; X32: movl ___guard_check_icall_fptr, %eax
- ; X32: calll *%eax
- ; X32-NEXT: calll *%ecx
-
- ; On x86_64, __guard_dispatch_icall_fptr tail calls the function, so there should be only one call instruction.
- ; X64-LABEL: func_optnone_cf
- ; X64: leaq target_func(%rip), %rax
- ; X64: movq __guard_dispatch_icall_fptr(%rip), %rcx
- ; X64: callq *%rcx
- ; X64-NOT: callq
-}
-attributes #1 = { noinline optnone }
-
-
-; Test that Control Flow Guard checks are correctly added in optimized code (common case).
-define i32 @func_cf() {
-entry:
- %func_ptr = alloca i32 ()*, align 8
- store i32 ()* @target_func, i32 ()** %func_ptr, align 8
- %0 = load i32 ()*, i32 ()** %func_ptr, align 8
- %1 = call i32 %0()
- ret i32 %1
-
- ; On i686, the call to __guard_check_icall_fptr should come immediately before the call to the target function.
- ; X32-LABEL: func_cf
- ; X32: movl $_target_func, %esi
- ; X32: movl $_target_func, %ecx
- ; X32: calll *___guard_check_icall_fptr
- ; X32-NEXT: calll *%esi
-
- ; On x86_64, __guard_dispatch_icall_fptr tail calls the function, so there should be only one call instruction.
- ; X64-LABEL: func_cf
- ; X64: leaq target_func(%rip), %rax
- ; X64: callq *__guard_dispatch_icall_fptr(%rip)
- ; X64-NOT: callq
-}
-
-
-; Test that Control Flow Guard checks are correctly added on invoke instructions.
-define i32 @func_cf_invoke() personality i8* bitcast (void ()* @h to i8*) {
-entry:
- %0 = alloca i32, align 4
- %func_ptr = alloca i32 ()*, align 8
- store i32 ()* @target_func, i32 ()** %func_ptr, align 8
- %1 = load i32 ()*, i32 ()** %func_ptr, align 8
- %2 = invoke i32 %1()
- to label %invoke.cont unwind label %lpad
-invoke.cont: ; preds = %entry
- ret i32 %2
-
-lpad: ; preds = %entry
- %tmp = landingpad { i8*, i32 }
- catch i8* null
- ret i32 -1
-
- ; On i686, the call to __guard_check_icall_fptr should come immediately before the call to the target function.
- ; X32-LABEL: func_cf_invoke
- ; X32: movl $_target_func, %esi
- ; X32: movl $_target_func, %ecx
- ; X32: calll *___guard_check_icall_fptr
- ; X32-NEXT: calll *%esi
- ; X32: # %invoke.cont
- ; X32: # %lpad
-
- ; On x86_64, __guard_dispatch_icall_fptr tail calls the function, so there should be only one call instruction.
- ; X64-LABEL: func_cf_invoke
- ; X64: leaq target_func(%rip), %rax
- ; X64: callq *__guard_dispatch_icall_fptr(%rip)
- ; X64-NOT: callq
- ; X64: # %invoke.cont
- ; X64: # %lpad
-}
-
-declare void @h()
-
-
-; Test that Control Flow Guard preserves floating point arguments.
-declare double @target_func_doubles(double, double, double, double)
-
-define double @func_cf_doubles() {
-entry:
- %func_ptr = alloca double (double, double, double, double)*, align 8
- store double (double, double, double, double)* @target_func_doubles, double (double, double, double, double)** %func_ptr, align 8
- %0 = load double (double, double, double, double)*, double (double, double, double, double)** %func_ptr, align 8
- %1 = call double %0(double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 4.000000e+00)
- ret double %1
-
- ; On i686, the call to __guard_check_icall_fptr should come immediately before the call to the target function.
- ; X32-LABEL: func_cf_doubles
- ; X32: movl $_target_func_doubles, %esi
- ; X32: movl $_target_func_doubles, %ecx
- ; X32: calll *___guard_check_icall_fptr
- ; X32: calll *%esi
-
-
- ; On x86_64, __guard_dispatch_icall_fptr tail calls the function, so there should be only one call instruction.
- ; X64-LABEL: func_cf_doubles
- ; X64: leaq target_func_doubles(%rip), %rax
- ; X64: movsd __real@3ff0000000000000(%rip), %xmm0
- ; X64: movsd __real@4000000000000000(%rip), %xmm1
- ; X64: movsd __real@4008000000000000(%rip), %xmm2
- ; X64: movsd __real@4010000000000000(%rip), %xmm3
- ; X64: callq *__guard_dispatch_icall_fptr(%rip)
- ; X64-NOT: callq
-}
-
-
-; Test that Control Flow Guard checks are correctly added for tail calls.
-define i32 @func_cf_tail() {
-entry:
- %func_ptr = alloca i32 ()*, align 8
- store i32 ()* @target_func, i32 ()** %func_ptr, align 8
- %0 = load i32 ()*, i32 ()** %func_ptr, align 8
- %1 = musttail call i32 %0()
- ret i32 %1
-
- ; On i686, the call to __guard_check_icall_fptr should come immediately before the call to the target function.
- ; X32-LABEL: func_cf_tail
- ; X32: movl $_target_func, %ecx
- ; X32: calll *___guard_check_icall_fptr
- ; X32: movl $_target_func, %eax
- ; X32: jmpl *%eax # TAILCALL
- ; X32-NOT: calll
-
- ; X64-LABEL: func_cf_tail
- ; X64: leaq target_func(%rip), %rax
- ; X64: movq __guard_dispatch_icall_fptr(%rip), %rcx
- ; X64: rex64 jmpq *%rcx # TAILCALL
- ; X64-NOT: callq
-}
-
-
-; Test that longjmp targets have public labels and are included in the .gljmp section.
-%struct._SETJMP_FLOAT128 = type { [2 x i64] }
-@buf1 = internal global [16 x %struct._SETJMP_FLOAT128] zeroinitializer, align 16
-
-define i32 @func_cf_setjmp() {
- %1 = alloca i32, align 4
- %2 = alloca i32, align 4
- store i32 0, i32* %1, align 4
- store i32 -1, i32* %2, align 4
- %3 = call i8* @llvm.frameaddress(i32 0)
- %4 = call i32 @_setjmp(i8* bitcast ([16 x %struct._SETJMP_FLOAT128]* @buf1 to i8*), i8* %3) #2
-
- ; X32-LABEL: func_cf_setjmp
- ; X32: calll __setjmp
- ; X32-NEXT: $cfgsj_func_cf_setjmp0:
-
- ; X64-LABEL: func_cf_setjmp
- ; X64: callq _setjmp
- ; X64-NEXT: $cfgsj_func_cf_setjmp0:
-
- %5 = call i8* @llvm.frameaddress(i32 0)
- %6 = call i32 @_setjmp(i8* bitcast ([16 x %struct._SETJMP_FLOAT128]* @buf1 to i8*), i8* %5) #2
-
- ; X32: calll __setjmp
- ; X32-NEXT: $cfgsj_func_cf_setjmp1:
-
- ; X64: callq _setjmp
- ; X64-NEXT: $cfgsj_func_cf_setjmp1:
-
- store i32 1, i32* %2, align 4
- %7 = load i32, i32* %2, align 4
- ret i32 %7
-
- ; X32: .section .gljmp$y,"dr"
- ; X32-NEXT: .symidx $cfgsj_func_cf_setjmp0
- ; X32-NEXT: .symidx $cfgsj_func_cf_setjmp1
-
- ; X64: .section .gljmp$y,"dr"
- ; X64-NEXT: .symidx $cfgsj_func_cf_setjmp0
- ; X64-NEXT: .symidx $cfgsj_func_cf_setjmp1
-}
-
-declare i8* @llvm.frameaddress(i32)
-
-; Function Attrs: returns_twice
-declare dso_local i32 @_setjmp(i8*, i8*) #2
-
-attributes #2 = { returns_twice }
-
-
-!llvm.module.flags = !{!0}
-!0 = !{i32 2, !"cfguard", i32 2}
+; RUN: llc < %s -mtriple=i686-pc-windows-msvc | FileCheck %s -check-prefix=X32 +; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s -check-prefix=X64 +; Control Flow Guard is currently only available on Windows + +; Test that Control Flow Guard checks are correctly added when required. + + +declare i32 @target_func() + + +; Test that Control Flow Guard checks are not added to functions with nocf_checks attribute. +define i32 @func_nocf_checks() #0 { +entry: + %func_ptr = alloca i32 ()*, align 8 + store i32 ()* @target_func, i32 ()** %func_ptr, align 8 + %0 = load i32 ()*, i32 ()** %func_ptr, align 8 + %1 = call i32 %0() + ret i32 %1 + + ; X32-LABEL: func_nocf_checks + ; X32: movl $_target_func, %eax + ; X32-NOT: __guard_check_icall_fptr + ; X32: calll *%eax + + ; X64-LABEL: func_nocf_checks + ; X64: leaq target_func(%rip), %rax + ; X64-NOT: __guard_dispatch_icall_fptr + ; X64: callq *%rax +} +attributes #0 = { nocf_check } + + +; Test that Control Flow Guard checks are added even at -O0. +; FIXME Ideally these checks should be added as a single call instruction, as in the optimized case. +define i32 @func_optnone_cf() #1 { +entry: + %func_ptr = alloca i32 ()*, align 8 + store i32 ()* @target_func, i32 ()** %func_ptr, align 8 + %0 = load i32 ()*, i32 ()** %func_ptr, align 8 + %1 = call i32 %0() + ret i32 %1 + + ; On i686, the call to __guard_check_icall_fptr should come immediately before the call to the target function. + ; X32-LABEL: func_optnone_cf + ; X32: leal _target_func, %eax + ; X32: movl %eax, (%esp) + ; X32: movl (%esp), %ecx + ; X32: movl ___guard_check_icall_fptr, %eax + ; X32: calll *%eax + ; X32-NEXT: calll *%ecx + + ; On x86_64, __guard_dispatch_icall_fptr tail calls the function, so there should be only one call instruction. + ; X64-LABEL: func_optnone_cf + ; X64: leaq target_func(%rip), %rax + ; X64: movq __guard_dispatch_icall_fptr(%rip), %rcx + ; X64: callq *%rcx + ; X64-NOT: callq +} +attributes #1 = { noinline optnone } + + +; Test that Control Flow Guard checks are correctly added in optimized code (common case). +define i32 @func_cf() { +entry: + %func_ptr = alloca i32 ()*, align 8 + store i32 ()* @target_func, i32 ()** %func_ptr, align 8 + %0 = load i32 ()*, i32 ()** %func_ptr, align 8 + %1 = call i32 %0() + ret i32 %1 + + ; On i686, the call to __guard_check_icall_fptr should come immediately before the call to the target function. + ; X32-LABEL: func_cf + ; X32: movl $_target_func, %esi + ; X32: movl $_target_func, %ecx + ; X32: calll *___guard_check_icall_fptr + ; X32-NEXT: calll *%esi + + ; On x86_64, __guard_dispatch_icall_fptr tail calls the function, so there should be only one call instruction. + ; X64-LABEL: func_cf + ; X64: leaq target_func(%rip), %rax + ; X64: callq *__guard_dispatch_icall_fptr(%rip) + ; X64-NOT: callq +} + + +; Test that Control Flow Guard checks are correctly added on invoke instructions. +define i32 @func_cf_invoke() personality i8* bitcast (void ()* @h to i8*) { +entry: + %0 = alloca i32, align 4 + %func_ptr = alloca i32 ()*, align 8 + store i32 ()* @target_func, i32 ()** %func_ptr, align 8 + %1 = load i32 ()*, i32 ()** %func_ptr, align 8 + %2 = invoke i32 %1() + to label %invoke.cont unwind label %lpad +invoke.cont: ; preds = %entry + ret i32 %2 + +lpad: ; preds = %entry + %tmp = landingpad { i8*, i32 } + catch i8* null + ret i32 -1 + + ; On i686, the call to __guard_check_icall_fptr should come immediately before the call to the target function. + ; X32-LABEL: func_cf_invoke + ; X32: movl $_target_func, %esi + ; X32: movl $_target_func, %ecx + ; X32: calll *___guard_check_icall_fptr + ; X32-NEXT: calll *%esi + ; X32: # %invoke.cont + ; X32: # %lpad + + ; On x86_64, __guard_dispatch_icall_fptr tail calls the function, so there should be only one call instruction. + ; X64-LABEL: func_cf_invoke + ; X64: leaq target_func(%rip), %rax + ; X64: callq *__guard_dispatch_icall_fptr(%rip) + ; X64-NOT: callq + ; X64: # %invoke.cont + ; X64: # %lpad +} + +declare void @h() + + +; Test that Control Flow Guard preserves floating point arguments. +declare double @target_func_doubles(double, double, double, double) + +define double @func_cf_doubles() { +entry: + %func_ptr = alloca double (double, double, double, double)*, align 8 + store double (double, double, double, double)* @target_func_doubles, double (double, double, double, double)** %func_ptr, align 8 + %0 = load double (double, double, double, double)*, double (double, double, double, double)** %func_ptr, align 8 + %1 = call double %0(double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 4.000000e+00) + ret double %1 + + ; On i686, the call to __guard_check_icall_fptr should come immediately before the call to the target function. + ; X32-LABEL: func_cf_doubles + ; X32: movl $_target_func_doubles, %esi + ; X32: movl $_target_func_doubles, %ecx + ; X32: calll *___guard_check_icall_fptr + ; X32: calll *%esi + + + ; On x86_64, __guard_dispatch_icall_fptr tail calls the function, so there should be only one call instruction. + ; X64-LABEL: func_cf_doubles + ; X64: leaq target_func_doubles(%rip), %rax + ; X64: movsd __real@3ff0000000000000(%rip), %xmm0 + ; X64: movsd __real@4000000000000000(%rip), %xmm1 + ; X64: movsd __real@4008000000000000(%rip), %xmm2 + ; X64: movsd __real@4010000000000000(%rip), %xmm3 + ; X64: callq *__guard_dispatch_icall_fptr(%rip) + ; X64-NOT: callq +} + + +; Test that Control Flow Guard checks are correctly added for tail calls. +define i32 @func_cf_tail() { +entry: + %func_ptr = alloca i32 ()*, align 8 + store i32 ()* @target_func, i32 ()** %func_ptr, align 8 + %0 = load i32 ()*, i32 ()** %func_ptr, align 8 + %1 = musttail call i32 %0() + ret i32 %1 + + ; On i686, the call to __guard_check_icall_fptr should come immediately before the call to the target function. + ; X32-LABEL: func_cf_tail + ; X32: movl $_target_func, %ecx + ; X32: calll *___guard_check_icall_fptr + ; X32: movl $_target_func, %eax + ; X32: jmpl *%eax # TAILCALL + ; X32-NOT: calll + + ; X64-LABEL: func_cf_tail + ; X64: leaq target_func(%rip), %rax + ; X64: movq __guard_dispatch_icall_fptr(%rip), %rcx + ; X64: rex64 jmpq *%rcx # TAILCALL + ; X64-NOT: callq +} + + +; Test that longjmp targets have public labels and are included in the .gljmp section. +%struct._SETJMP_FLOAT128 = type { [2 x i64] } +@buf1 = internal global [16 x %struct._SETJMP_FLOAT128] zeroinitializer, align 16 + +define i32 @func_cf_setjmp() { + %1 = alloca i32, align 4 + %2 = alloca i32, align 4 + store i32 0, i32* %1, align 4 + store i32 -1, i32* %2, align 4 + %3 = call i8* @llvm.frameaddress(i32 0) + %4 = call i32 @_setjmp(i8* bitcast ([16 x %struct._SETJMP_FLOAT128]* @buf1 to i8*), i8* %3) #2 + + ; X32-LABEL: func_cf_setjmp + ; X32: calll __setjmp + ; X32-NEXT: $cfgsj_func_cf_setjmp0: + + ; X64-LABEL: func_cf_setjmp + ; X64: callq _setjmp + ; X64-NEXT: $cfgsj_func_cf_setjmp0: + + %5 = call i8* @llvm.frameaddress(i32 0) + %6 = call i32 @_setjmp(i8* bitcast ([16 x %struct._SETJMP_FLOAT128]* @buf1 to i8*), i8* %5) #2 + + ; X32: calll __setjmp + ; X32-NEXT: $cfgsj_func_cf_setjmp1: + + ; X64: callq _setjmp + ; X64-NEXT: $cfgsj_func_cf_setjmp1: + + store i32 1, i32* %2, align 4 + %7 = load i32, i32* %2, align 4 + ret i32 %7 + + ; X32: .section .gljmp$y,"dr" + ; X32-NEXT: .symidx $cfgsj_func_cf_setjmp0 + ; X32-NEXT: .symidx $cfgsj_func_cf_setjmp1 + + ; X64: .section .gljmp$y,"dr" + ; X64-NEXT: .symidx $cfgsj_func_cf_setjmp0 + ; X64-NEXT: .symidx $cfgsj_func_cf_setjmp1 +} + +declare i8* @llvm.frameaddress(i32) + +; Function Attrs: returns_twice +declare dso_local i32 @_setjmp(i8*, i8*) #2 + +attributes #2 = { returns_twice } + + +!llvm.module.flags = !{!0} +!0 = !{i32 2, !"cfguard", i32 2} diff --git a/llvm/test/CodeGen/X86/cfguard-module-flag.ll b/llvm/test/CodeGen/X86/cfguard-module-flag.ll index 1b2e71c1a45..0ed58b392aa 100644 --- a/llvm/test/CodeGen/X86/cfguard-module-flag.ll +++ b/llvm/test/CodeGen/X86/cfguard-module-flag.ll @@ -1,26 +1,26 @@ -
-; RUN: llc < %s -mtriple=i686-pc-windows-msvc | FileCheck %s -check-prefix=X32
-; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s -check-prefix=X64
-; 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
-
- ; X32-NOT: __guard_check_icall_fptr
- ; X64-NOT: __guard_dispatch_icall_fptr
-}
-
-!llvm.module.flags = !{!0}
-!0 = !{i32 2, !"cfguard", i32 1}
+ +; RUN: llc < %s -mtriple=i686-pc-windows-msvc | FileCheck %s -check-prefix=X32 +; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s -check-prefix=X64 +; 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 + + ; X32-NOT: __guard_check_icall_fptr + ; X64-NOT: __guard_dispatch_icall_fptr +} + +!llvm.module.flags = !{!0} +!0 = !{i32 2, !"cfguard", i32 1} diff --git a/llvm/test/CodeGen/X86/cfguard-x86-64-vectorcall.ll b/llvm/test/CodeGen/X86/cfguard-x86-64-vectorcall.ll index a554ebeeb90..be7acc53137 100644 --- a/llvm/test/CodeGen/X86/cfguard-x86-64-vectorcall.ll +++ b/llvm/test/CodeGen/X86/cfguard-x86-64-vectorcall.ll @@ -1,38 +1,38 @@ -; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s -check-prefix=X64
-; Control Flow Guard is currently only available on Windows
-
-
-; Test that Control Flow Guard checks are correctly added for x86_64 vector calls.
-define void @func_cf_vector_x64(void (%struct.HVA)* %0, %struct.HVA* %1) #0 {
-entry:
- %2 = alloca %struct.HVA, align 8
- %3 = bitcast %struct.HVA* %2 to i8*
- %4 = bitcast %struct.HVA* %1 to i8*
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 32, i1 false)
- %5 = load %struct.HVA, %struct.HVA* %2, align 8
- call x86_vectorcallcc void %0(%struct.HVA inreg %5)
- ret void
-
- ; X64-LABEL: func_cf_vector_x64
- ; X64: movq %rcx, %rax
- ; X64: movups (%rdx), %xmm0
- ; X64: movups 16(%rdx), %xmm1
- ; X64: movaps %xmm0, 32(%rsp)
- ; X64: movaps %xmm1, 48(%rsp)
- ; X64: movsd 32(%rsp), %xmm0 # xmm0 = mem[0],zero
- ; X64: movsd 40(%rsp), %xmm1 # xmm1 = mem[0],zero
- ; X64: movsd 48(%rsp), %xmm2 # xmm2 = mem[0],zero
- ; X64: movsd 56(%rsp), %xmm3 # xmm3 = mem[0],zero
- ; X64: callq *__guard_dispatch_icall_fptr(%rip)
- ; X64-NOT: callq
-}
-attributes #0 = { "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" }
-
-%struct.HVA = type { double, double, double, double }
-
-declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1 immarg) #1
-attributes #1 = { argmemonly nounwind willreturn }
-
-
-!llvm.module.flags = !{!0}
-!0 = !{i32 2, !"cfguard", i32 2}
+; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s -check-prefix=X64 +; Control Flow Guard is currently only available on Windows + + +; Test that Control Flow Guard checks are correctly added for x86_64 vector calls. +define void @func_cf_vector_x64(void (%struct.HVA)* %0, %struct.HVA* %1) #0 { +entry: + %2 = alloca %struct.HVA, align 8 + %3 = bitcast %struct.HVA* %2 to i8* + %4 = bitcast %struct.HVA* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %3, i8* align 8 %4, i64 32, i1 false) + %5 = load %struct.HVA, %struct.HVA* %2, align 8 + call x86_vectorcallcc void %0(%struct.HVA inreg %5) + ret void + + ; X64-LABEL: func_cf_vector_x64 + ; X64: movq %rcx, %rax + ; X64: movups (%rdx), %xmm0 + ; X64: movups 16(%rdx), %xmm1 + ; X64: movaps %xmm0, 32(%rsp) + ; X64: movaps %xmm1, 48(%rsp) + ; X64: movsd 32(%rsp), %xmm0 # xmm0 = mem[0],zero + ; X64: movsd 40(%rsp), %xmm1 # xmm1 = mem[0],zero + ; X64: movsd 48(%rsp), %xmm2 # xmm2 = mem[0],zero + ; X64: movsd 56(%rsp), %xmm3 # xmm3 = mem[0],zero + ; X64: callq *__guard_dispatch_icall_fptr(%rip) + ; X64-NOT: callq +} +attributes #0 = { "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" } + +%struct.HVA = type { double, double, double, double } + +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1 immarg) #1 +attributes #1 = { argmemonly nounwind willreturn } + + +!llvm.module.flags = !{!0} +!0 = !{i32 2, !"cfguard", i32 2} diff --git a/llvm/test/CodeGen/X86/cfguard-x86-vectorcall.ll b/llvm/test/CodeGen/X86/cfguard-x86-vectorcall.ll index 0f31f5ba4b6..25e3691913c 100644 --- a/llvm/test/CodeGen/X86/cfguard-x86-vectorcall.ll +++ b/llvm/test/CodeGen/X86/cfguard-x86-vectorcall.ll @@ -1,43 +1,43 @@ -; RUN: llc < %s -mtriple=i686-pc-windows-msvc | FileCheck %s -check-prefix=X32
-; Control Flow Guard is currently only available on Windows
-
-
-; Test that Control Flow Guard checks are correctly added for x86 vector calls.
-define void @func_cf_vector_x86(void (%struct.HVA)* %0, %struct.HVA* %1) #0 {
-entry:
- %2 = alloca %struct.HVA, align 8
- %3 = bitcast %struct.HVA* %2 to i8*
- %4 = bitcast %struct.HVA* %1 to i8*
- call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 32, i1 false)
- %5 = load %struct.HVA, %struct.HVA* %2, align 8
- call x86_vectorcallcc void %0(%struct.HVA inreg %5)
- ret void
-
- ; X32-LABEL: func_cf_vector_x86
- ; X32: movl 12(%ebp), %eax
- ; X32: movl 8(%ebp), %ecx
- ; X32: movsd 24(%eax), %xmm4 # xmm4 = mem[0],zero
- ; X32: movsd %xmm4, 24(%esp)
- ; X32: movsd 16(%eax), %xmm5 # xmm5 = mem[0],zero
- ; X32: movsd %xmm5, 16(%esp)
- ; X32: movsd (%eax), %xmm6 # xmm6 = mem[0],zero
- ; X32: movsd 8(%eax), %xmm7 # xmm7 = mem[0],zero
- ; X32: movsd %xmm7, 8(%esp)
- ; X32: movsd %xmm6, (%esp)
- ; X32: calll *___guard_check_icall_fptr
- ; X32: movaps %xmm6, %xmm0
- ; X32: movaps %xmm7, %xmm1
- ; X32: movaps %xmm5, %xmm2
- ; X32: movaps %xmm4, %xmm3
- ; X32: calll *%ecx
-}
-attributes #0 = { "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" }
-
-%struct.HVA = type { double, double, double, double }
-
-declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1 immarg) #1
-attributes #1 = { argmemonly nounwind willreturn }
-
-
-!llvm.module.flags = !{!0}
-!0 = !{i32 2, !"cfguard", i32 2}
+; RUN: llc < %s -mtriple=i686-pc-windows-msvc | FileCheck %s -check-prefix=X32 +; Control Flow Guard is currently only available on Windows + + +; Test that Control Flow Guard checks are correctly added for x86 vector calls. +define void @func_cf_vector_x86(void (%struct.HVA)* %0, %struct.HVA* %1) #0 { +entry: + %2 = alloca %struct.HVA, align 8 + %3 = bitcast %struct.HVA* %2 to i8* + %4 = bitcast %struct.HVA* %1 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 32, i1 false) + %5 = load %struct.HVA, %struct.HVA* %2, align 8 + call x86_vectorcallcc void %0(%struct.HVA inreg %5) + ret void + + ; X32-LABEL: func_cf_vector_x86 + ; X32: movl 12(%ebp), %eax + ; X32: movl 8(%ebp), %ecx + ; X32: movsd 24(%eax), %xmm4 # xmm4 = mem[0],zero + ; X32: movsd %xmm4, 24(%esp) + ; X32: movsd 16(%eax), %xmm5 # xmm5 = mem[0],zero + ; X32: movsd %xmm5, 16(%esp) + ; X32: movsd (%eax), %xmm6 # xmm6 = mem[0],zero + ; X32: movsd 8(%eax), %xmm7 # xmm7 = mem[0],zero + ; X32: movsd %xmm7, 8(%esp) + ; X32: movsd %xmm6, (%esp) + ; X32: calll *___guard_check_icall_fptr + ; X32: movaps %xmm6, %xmm0 + ; X32: movaps %xmm7, %xmm1 + ; X32: movaps %xmm5, %xmm2 + ; X32: movaps %xmm4, %xmm3 + ; X32: calll *%ecx +} +attributes #0 = { "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" } + +%struct.HVA = type { double, double, double, double } + +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1 immarg) #1 +attributes #1 = { argmemonly nounwind willreturn } + + +!llvm.module.flags = !{!0} +!0 = !{i32 2, !"cfguard", i32 2} |

