74 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes2; Test that the strcpy library call simplifier also works when the string3; libcall arguments are in a non-zero address space.4; RUN: opt < %s -passes=instcombine -S | FileCheck %s5target datalayout = "e-m:e-p200:128:128:128:64-p:64:64-A200-P200-G200"6 7@str = private unnamed_addr addrspace(200) constant [17 x i8] c"exactly 16 chars\00", align 18 9declare ptr addrspace(200) @strcpy(ptr addrspace(200), ptr addrspace(200)) addrspace(200)10declare ptr addrspace(200) @stpcpy(ptr addrspace(200), ptr addrspace(200)) addrspace(200)11declare ptr addrspace(200) @strncpy(ptr addrspace(200), ptr addrspace(200), i64) addrspace(200)12declare ptr addrspace(200) @stpncpy(ptr addrspace(200), ptr addrspace(200), i64) addrspace(200)13 14define void @test_strcpy_to_memcpy(ptr addrspace(200) %dst) addrspace(200) nounwind {15; CHECK-LABEL: define {{[^@]+}}@test_strcpy_to_memcpy16; CHECK-SAME: (ptr addrspace(200) [[DST:%.*]]) addrspace(200) #[[ATTR1:[0-9]+]] {17; CHECK-NEXT: entry:18; CHECK-NEXT: call addrspace(200) void @llvm.memcpy.p200.p200.i64(ptr addrspace(200) noundef align 1 dereferenceable(17) [[DST]], ptr addrspace(200) noundef align 1 dereferenceable(17) @str, i64 17, i1 false)19; CHECK-NEXT: ret void20;21entry:22 %call = call ptr addrspace(200) @strcpy(ptr addrspace(200) %dst, ptr addrspace(200) @str)23 ret void24}25 26define void @test_stpcpy_to_memcpy(ptr addrspace(200) %dst) addrspace(200) nounwind {27; CHECK-LABEL: define {{[^@]+}}@test_stpcpy_to_memcpy28; CHECK-SAME: (ptr addrspace(200) [[DST:%.*]]) addrspace(200) #[[ATTR1]] {29; CHECK-NEXT: entry:30; CHECK-NEXT: call addrspace(200) void @llvm.memcpy.p200.p200.i64(ptr addrspace(200) noundef align 1 dereferenceable(17) [[DST]], ptr addrspace(200) noundef align 1 dereferenceable(17) @str, i64 17, i1 false)31; CHECK-NEXT: ret void32;33entry:34 %call = call ptr addrspace(200) @stpcpy(ptr addrspace(200) %dst, ptr addrspace(200) @str)35 ret void36}37 38define void @test_stpcpy_to_strcpy(ptr addrspace(200) %dst, ptr addrspace(200) %src) addrspace(200) nounwind {39; CHECK-LABEL: define {{[^@]+}}@test_stpcpy_to_strcpy40; CHECK-SAME: (ptr addrspace(200) [[DST:%.*]], ptr addrspace(200) [[SRC:%.*]]) addrspace(200) #[[ATTR1]] {41; CHECK-NEXT: entry:42; CHECK-NEXT: [[STRCPY:%.*]] = call addrspace(200) ptr addrspace(200) @strcpy(ptr addrspace(200) noundef [[DST]], ptr addrspace(200) noundef [[SRC]])43; CHECK-NEXT: ret void44;45entry:46 %call = call ptr addrspace(200) @stpcpy(ptr addrspace(200) %dst, ptr addrspace(200) %src)47 ret void48}49 50 51define void @test_strncpy_to_memcpy(ptr addrspace(200) %dst) addrspace(200) nounwind {52; CHECK-LABEL: define {{[^@]+}}@test_strncpy_to_memcpy53; CHECK-SAME: (ptr addrspace(200) [[DST:%.*]]) addrspace(200) #[[ATTR1]] {54; CHECK-NEXT: entry:55; CHECK-NEXT: call addrspace(200) void @llvm.memcpy.p200.p200.i64(ptr addrspace(200) noundef align 1 dereferenceable(17) [[DST]], ptr addrspace(200) noundef align 1 dereferenceable(17) @str, i64 17, i1 false)56; CHECK-NEXT: ret void57;58entry:59 %call = call ptr addrspace(200) @strncpy(ptr addrspace(200) %dst, ptr addrspace(200) @str, i64 17)60 ret void61}62 63define void @test_stpncpy_to_memcpy(ptr addrspace(200) %dst) addrspace(200) nounwind {64; CHECK-LABEL: define {{[^@]+}}@test_stpncpy_to_memcpy65; CHECK-SAME: (ptr addrspace(200) [[DST:%.*]]) addrspace(200) #[[ATTR1]] {66; CHECK-NEXT: entry:67; CHECK-NEXT: call addrspace(200) void @llvm.memcpy.p200.p200.i64(ptr addrspace(200) noundef align 1 dereferenceable(17) [[DST]], ptr addrspace(200) noundef align 1 dereferenceable(17) @str, i64 17, i1 false)68; CHECK-NEXT: ret void69;70entry:71 %call = call ptr addrspace(200) @stpncpy(ptr addrspace(200) %dst, ptr addrspace(200) @str, i64 17)72 ret void73}74