|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: llc -mtriple=i386-pc-windows-msvc < %s -o - | FileCheck -check-prefix=MSVC-X86 %s |
| 3 | +; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s -o - | FileCheck -check-prefix=MSVC-X64 %s |
| 4 | + |
| 5 | +; Make sure fastisel falls back and does something secure. |
| 6 | +; RUN: llc -mtriple=i686-pc-windows-msvc -O0 < %s -o - | FileCheck -check-prefix=MSVC-X86-O0 %s |
| 7 | +; RUN: llc -mtriple=x86_64-pc-windows-msvc -O0 < %s -o - | FileCheck -check-prefix=MSVC-X64-O0 %s |
| 8 | + |
| 9 | +@"\01LC" = internal constant [11 x i8] c"buf == %s\0A\00" ; <ptr> [#uses=1] |
| 10 | + |
| 11 | +define void @test(ptr %a) nounwind ssp minsize { |
| 12 | +; MSVC-X86-LABEL: test: |
| 13 | +; MSVC-X86: # %bb.0: # %entry |
| 14 | +; MSVC-X86-NEXT: pushl %esi |
| 15 | +; MSVC-X86-NEXT: subl $12, %esp |
| 16 | +; MSVC-X86-NEXT: movl ___security_cookie, %eax |
| 17 | +; MSVC-X86-NEXT: xorl %esp, %eax |
| 18 | +; MSVC-X86-NEXT: movl %eax, {{[0-9]+}}(%esp) |
| 19 | +; MSVC-X86-NEXT: movl %esp, %esi |
| 20 | +; MSVC-X86-NEXT: pushl {{[0-9]+}}(%esp) |
| 21 | +; MSVC-X86-NEXT: pushl %esi |
| 22 | +; MSVC-X86-NEXT: calll _strcpy |
| 23 | +; MSVC-X86-NEXT: popl %ecx |
| 24 | +; MSVC-X86-NEXT: popl %edx |
| 25 | +; MSVC-X86-NEXT: pushl %esi |
| 26 | +; MSVC-X86-NEXT: pushl $LC |
| 27 | +; MSVC-X86-NEXT: calll _printf |
| 28 | +; MSVC-X86-NEXT: popl %ecx |
| 29 | +; MSVC-X86-NEXT: popl %edx |
| 30 | +; MSVC-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx |
| 31 | +; MSVC-X86-NEXT: xorl %esp, %ecx |
| 32 | +; MSVC-X86-NEXT: calll @__security_check_cookie@4 |
| 33 | +; MSVC-X86-NEXT: addl $12, %esp |
| 34 | +; MSVC-X86-NEXT: popl %esi |
| 35 | +; MSVC-X86-NEXT: retl |
| 36 | +; |
| 37 | +; MSVC-X64-LABEL: test: |
| 38 | +; MSVC-X64: # %bb.0: # %entry |
| 39 | +; MSVC-X64-NEXT: pushq %rsi |
| 40 | +; MSVC-X64-NEXT: subq $64, %rsp |
| 41 | +; MSVC-X64-NEXT: movq %rcx, %rdx |
| 42 | +; MSVC-X64-NEXT: movq __security_cookie(%rip), %rax |
| 43 | +; MSVC-X64-NEXT: xorq %rsp, %rax |
| 44 | +; MSVC-X64-NEXT: movq %rax, {{[0-9]+}}(%rsp) |
| 45 | +; MSVC-X64-NEXT: movq %rcx, {{[0-9]+}}(%rsp) |
| 46 | +; MSVC-X64-NEXT: leaq {{[0-9]+}}(%rsp), %rsi |
| 47 | +; MSVC-X64-NEXT: movq %rsi, %rcx |
| 48 | +; MSVC-X64-NEXT: callq strcpy |
| 49 | +; MSVC-X64-NEXT: leaq LC(%rip), %rcx |
| 50 | +; MSVC-X64-NEXT: movq %rsi, %rdx |
| 51 | +; MSVC-X64-NEXT: callq printf |
| 52 | +; MSVC-X64-NEXT: movq {{[0-9]+}}(%rsp), %rcx |
| 53 | +; MSVC-X64-NEXT: xorq %rsp, %rcx |
| 54 | +; MSVC-X64-NEXT: callq __security_check_cookie |
| 55 | +; MSVC-X64-NEXT: addq $64, %rsp |
| 56 | +; MSVC-X64-NEXT: popq %rsi |
| 57 | +; MSVC-X64-NEXT: retq |
| 58 | +; |
| 59 | +; MSVC-X86-O0-LABEL: test: |
| 60 | +; MSVC-X86-O0: # %bb.0: # %entry |
| 61 | +; MSVC-X86-O0-NEXT: subl $20, %esp |
| 62 | +; MSVC-X86-O0-NEXT: movl {{[0-9]+}}(%esp), %eax |
| 63 | +; MSVC-X86-O0-NEXT: movl ___security_cookie, %eax |
| 64 | +; MSVC-X86-O0-NEXT: xorl %esp, %eax |
| 65 | +; MSVC-X86-O0-NEXT: movl %eax, {{[0-9]+}}(%esp) |
| 66 | +; MSVC-X86-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx |
| 67 | +; MSVC-X86-O0-NEXT: movl %esp, %eax |
| 68 | +; MSVC-X86-O0-NEXT: movl %ecx, 4(%eax) |
| 69 | +; MSVC-X86-O0-NEXT: leal {{[0-9]+}}(%esp), %ecx |
| 70 | +; MSVC-X86-O0-NEXT: movl %ecx, (%eax) |
| 71 | +; MSVC-X86-O0-NEXT: calll _strcpy |
| 72 | +; MSVC-X86-O0-NEXT: leal LC, %ecx |
| 73 | +; MSVC-X86-O0-NEXT: leal {{[0-9]+}}(%esp), %eax |
| 74 | +; MSVC-X86-O0-NEXT: movl %ecx, (%esp) |
| 75 | +; MSVC-X86-O0-NEXT: movl %eax, {{[0-9]+}}(%esp) |
| 76 | +; MSVC-X86-O0-NEXT: calll _printf |
| 77 | +; MSVC-X86-O0-NEXT: # %bb.1: # %return |
| 78 | +; MSVC-X86-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx |
| 79 | +; MSVC-X86-O0-NEXT: xorl %esp, %ecx |
| 80 | +; MSVC-X86-O0-NEXT: calll @__security_check_cookie@4 |
| 81 | +; MSVC-X86-O0-NEXT: addl $20, %esp |
| 82 | +; MSVC-X86-O0-NEXT: retl |
| 83 | +; |
| 84 | +; MSVC-X64-O0-LABEL: test: |
| 85 | +; MSVC-X64-O0: # %bb.0: # %entry |
| 86 | +; MSVC-X64-O0-NEXT: subq $56, %rsp |
| 87 | +; MSVC-X64-O0-NEXT: movq __security_cookie(%rip), %rax |
| 88 | +; MSVC-X64-O0-NEXT: xorq %rsp, %rax |
| 89 | +; MSVC-X64-O0-NEXT: movq %rax, {{[0-9]+}}(%rsp) |
| 90 | +; MSVC-X64-O0-NEXT: movq %rcx, {{[0-9]+}}(%rsp) |
| 91 | +; MSVC-X64-O0-NEXT: movq {{[0-9]+}}(%rsp), %rdx |
| 92 | +; MSVC-X64-O0-NEXT: leaq {{[0-9]+}}(%rsp), %rcx |
| 93 | +; MSVC-X64-O0-NEXT: callq strcpy |
| 94 | +; MSVC-X64-O0-NEXT: leaq LC(%rip), %rcx |
| 95 | +; MSVC-X64-O0-NEXT: leaq {{[0-9]+}}(%rsp), %rdx |
| 96 | +; MSVC-X64-O0-NEXT: callq printf |
| 97 | +; MSVC-X64-O0-NEXT: # %bb.1: # %return |
| 98 | +; MSVC-X64-O0-NEXT: movq {{[0-9]+}}(%rsp), %rcx |
| 99 | +; MSVC-X64-O0-NEXT: xorq %rsp, %rcx |
| 100 | +; MSVC-X64-O0-NEXT: callq __security_check_cookie |
| 101 | +; MSVC-X64-O0-NEXT: addq $56, %rsp |
| 102 | +; MSVC-X64-O0-NEXT: retq |
| 103 | +entry: |
| 104 | + %a_addr = alloca ptr ; <ptr> [#uses=2] |
| 105 | + %buf = alloca [8 x i8] ; <ptr> [#uses=2] |
| 106 | + store ptr %a, ptr %a_addr |
| 107 | + %0 = load ptr, ptr %a_addr, align 4 ; <ptr> [#uses=1] |
| 108 | + %1 = call ptr @strcpy(ptr %buf, ptr %0) nounwind ; <ptr> [#uses=0] |
| 109 | + %2 = call i32 (ptr, ...) @printf(ptr @"\01LC", ptr %buf) nounwind ; <i32> [#uses=0] |
| 110 | + br label %return |
| 111 | + |
| 112 | +return: ; preds = %entry |
| 113 | + ret void |
| 114 | +} |
| 115 | + |
| 116 | +declare ptr @strcpy(ptr, ptr) nounwind |
| 117 | + |
| 118 | +declare i32 @printf(ptr, ...) nounwind |
| 119 | + |
0 commit comments