1 ; Test that the StrCpyOptimizer works correctly
2 ; RUN: opt < %s -simplify-libcalls -S | FileCheck %s
4 ; This transformation requires the pointer size, as it assumes that size_t is
5 ; the size of a pointer.
6 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32"
8 @hello = constant [6 x i8] c"hello\00"
10 declare i8* @strcpy(i8*, i8*)
12 declare i8* @__strcpy_chk(i8*, i8*, i32) nounwind
14 declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readonly
20 %target = alloca [1024 x i8]
21 %arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0
22 %arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0
23 %rslt1 = call i8* @strcpy( i8* %arg1, i8* %arg2 )
24 ; CHECK: @llvm.memcpy.p0i8.p0i8.i32
30 %target = alloca [1024 x i8]
31 %arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0
32 %arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0
33 %tmp1 = call i32 @llvm.objectsize.i32(i8* %arg1, i1 false)
34 %rslt1 = call i8* @__strcpy_chk(i8* %arg1, i8* %arg2, i32 %tmp1)
35 ; CHECK: @__memcpy_chk