xref: /llvm-project/llvm/test/CodeGen/X86/ps4-ssp-nop.ll (revision 2f448bf509432c1a19ec46ab8cbc7353c03c6280)
1; Verify that a ud2 is generated after the call to __stack_chk_fail.
2
3; RUN: llc < %s -mtriple=x86_64-scei-ps4 -enable-selectiondag-sp=false -O0 -o - | FileCheck %s
4; RUN: llc < %s -mtriple=x86_64-sie-ps5  -enable-selectiondag-sp=false -O0 -o - | FileCheck %s
5; RUN: llc < %s -mtriple=x86_64-scei-ps4 -enable-selectiondag-sp=false -O2 -o - | FileCheck %s
6; RUN: llc < %s -mtriple=x86_64-sie-ps5  -enable-selectiondag-sp=false -O2 -o - | FileCheck %s
7; RUN: llc < %s -mtriple=x86_64-scei-ps4 -enable-selectiondag-sp=true  -O0 -o - | FileCheck %s
8; RUN: llc < %s -mtriple=x86_64-sie-ps5  -enable-selectiondag-sp=true  -O0 -o - | FileCheck %s
9; RUN: llc < %s -mtriple=x86_64-scei-ps4 -enable-selectiondag-sp=true  -O2 -o - | FileCheck %s
10; RUN: llc < %s -mtriple=x86_64-sie-ps5  -enable-selectiondag-sp=true  -O2 -o - | FileCheck %s
11
12
13; CHECK: check_input:
14; CHECK: callq __stack_chk_fail
15; CHECK-NEXT: ud2
16; CHECK: .size	check_input
17; CHECK-NEXT: .cfi_endproc
18
19@.str = private unnamed_addr constant [37 x i8] c"????????????????????????????????????\00", align 1
20
21define signext i8 @check_input(ptr %input) nounwind uwtable ssp {
22entry:
23  %input.addr = alloca ptr, align 8
24  %buf = alloca [16 x i8], align 16
25  store ptr %input, ptr %input.addr, align 8
26  %0 = load ptr, ptr %input.addr, align 8
27  %call = call ptr @strcpy(ptr %buf, ptr %0) nounwind
28  %1 = load i8, ptr %buf, align 1
29  ret i8 %1
30}
31
32declare ptr @strcpy(ptr, ptr) nounwind
33
34define i32 @main() nounwind uwtable ssp {
35entry:
36  %retval = alloca i32, align 4
37  store i32 0, ptr %retval
38  %call = call signext i8 @check_input(ptr @.str)
39  %conv = sext i8 %call to i32
40  ret i32 %conv
41}
42