xref: /aosp_15_r20/external/llvm/test/Transforms/MemCpyOpt/memcpy-undef.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -basicaa -memcpyopt -S | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
4*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-apple-macosx10.8.0"
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker%struct.foo = type { i8, [7 x i8], i32 }
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Workerdefine i32 @test1(%struct.foo* nocapture %foobie) nounwind noinline ssp uwtable {
9*9880d681SAndroid Build Coastguard Worker  %bletch.sroa.1 = alloca [7 x i8], align 1
10*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr inbounds %struct.foo, %struct.foo* %foobie, i64 0, i32 0
11*9880d681SAndroid Build Coastguard Worker  store i8 98, i8* %1, align 4
12*9880d681SAndroid Build Coastguard Worker  %2 = getelementptr inbounds %struct.foo, %struct.foo* %foobie, i64 0, i32 1, i64 0
13*9880d681SAndroid Build Coastguard Worker  %3 = getelementptr inbounds [7 x i8], [7 x i8]* %bletch.sroa.1, i64 0, i64 0
14*9880d681SAndroid Build Coastguard Worker  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* %3, i64 7, i32 1, i1 false)
15*9880d681SAndroid Build Coastguard Worker  %4 = getelementptr inbounds %struct.foo, %struct.foo* %foobie, i64 0, i32 2
16*9880d681SAndroid Build Coastguard Worker  store i32 20, i32* %4, align 4
17*9880d681SAndroid Build Coastguard Worker  ret i32 undef
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; Check that the memcpy is removed.
20*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test1(
21*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: call void @llvm.memcpy
22*9880d681SAndroid Build Coastguard Worker}
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Workerdefine void @test2(i8* sret noalias nocapture %out, i8* %in) nounwind noinline ssp uwtable {
25*9880d681SAndroid Build Coastguard Worker  call void @llvm.lifetime.start(i64 8, i8* %in)
26*9880d681SAndroid Build Coastguard Worker  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %out, i8* %in, i64 8, i32 1, i1 false)
27*9880d681SAndroid Build Coastguard Worker  ret void
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker; Check that the memcpy is removed.
30*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test2(
31*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: call void @llvm.memcpy
32*9880d681SAndroid Build Coastguard Worker}
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard Workerdefine void @test3(i8* sret noalias nocapture %out, i8* %in) nounwind noinline ssp uwtable {
35*9880d681SAndroid Build Coastguard Worker  call void @llvm.lifetime.start(i64 4, i8* %in)
36*9880d681SAndroid Build Coastguard Worker  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %out, i8* %in, i64 8, i32 1, i1 false)
37*9880d681SAndroid Build Coastguard Worker  ret void
38*9880d681SAndroid Build Coastguard Worker
39*9880d681SAndroid Build Coastguard Worker; Check that the memcpy is not removed.
40*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test3(
41*9880d681SAndroid Build Coastguard Worker; CHECK: call void @llvm.memcpy
42*9880d681SAndroid Build Coastguard Worker}
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.lifetime.start(i64, i8* nocapture) nounwind
47