xref: /aosp_15_r20/external/llvm/test/CodeGen/SystemZ/strcpy-nobuiltin.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; Test that strcmp won't be converted to MVST if calls are
2*9880d681SAndroid Build Coastguard Worker; marked with nobuiltin, eg. for sanitizers.
3*9880d681SAndroid Build Coastguard Worker;
4*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workerdeclare i8 *@strcpy(i8 *%dest, i8 *%src)
7*9880d681SAndroid Build Coastguard Workerdeclare i8 *@stpcpy(i8 *%dest, i8 *%src)
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker; Check strcpy.
10*9880d681SAndroid Build Coastguard Workerdefine i8 *@f1(i8 *%dest, i8 *%src) {
11*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f1:
12*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: mvst
13*9880d681SAndroid Build Coastguard Worker; CHECK: brasl %r14, strcpy
14*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
15*9880d681SAndroid Build Coastguard Worker  %res = call i8 *@strcpy(i8 *%dest, i8 *%src) nobuiltin
16*9880d681SAndroid Build Coastguard Worker  ret i8 *%res
17*9880d681SAndroid Build Coastguard Worker}
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; Check stpcpy.
20*9880d681SAndroid Build Coastguard Workerdefine i8 *@f2(i8 *%dest, i8 *%src) {
21*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f2:
22*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: mvst
23*9880d681SAndroid Build Coastguard Worker; CHECK: brasl %r14, stpcpy
24*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
25*9880d681SAndroid Build Coastguard Worker  %res = call i8 *@stpcpy(i8 *%dest, i8 *%src) nobuiltin
26*9880d681SAndroid Build Coastguard Worker  ret i8 *%res
27*9880d681SAndroid Build Coastguard Worker}
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker; Check correct operation with other loads and stores.  The load must
30*9880d681SAndroid Build Coastguard Worker; come before the loop and the store afterwards.
31*9880d681SAndroid Build Coastguard Workerdefine i32 @f3(i32 %dummy, i8 *%dest, i8 *%src, i32 *%resptr, i32 *%storeptr) {
32*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f3:
33*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: l [[REG1:%r[0-9]+]], 0(%r5)
34*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: mvst
35*9880d681SAndroid Build Coastguard Worker; CHECK: brasl %r14, strcpy
36*9880d681SAndroid Build Coastguard Worker; CHECK: mvhi 0(%r6), 0
37*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
38*9880d681SAndroid Build Coastguard Worker  %res = load i32 , i32 *%resptr
39*9880d681SAndroid Build Coastguard Worker  %unused = call i8 *@strcpy(i8 *%dest, i8 *%src) nobuiltin
40*9880d681SAndroid Build Coastguard Worker  store i32 0, i32 *%storeptr
41*9880d681SAndroid Build Coastguard Worker  ret i32 %res
42*9880d681SAndroid Build Coastguard Worker}
43