A memcpy out of an fresh alloca is a no-op, delete it. Patch by Patrick Walton!
[oota-llvm.git] / test / Transforms / MemCpyOpt / memcpy-undef.ll
1 ; RUN: opt < %s -basicaa -memcpyopt -S | FileCheck %s
2
3 target 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 target triple = "x86_64-apple-macosx10.8.0"
5
6 %struct.foo = type { i8, [7 x i8], i32 }
7
8 define i32 @test1(%struct.foo* nocapture %foobie) nounwind noinline ssp uwtable {
9   %bletch.sroa.1 = alloca [7 x i8], align 1
10   %1 = getelementptr inbounds %struct.foo* %foobie, i64 0, i32 0
11   store i8 98, i8* %1, align 4
12   %2 = getelementptr inbounds %struct.foo* %foobie, i64 0, i32 1, i64 0
13   %3 = getelementptr inbounds [7 x i8]* %bletch.sroa.1, i64 0, i64 0
14   call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* %3, i64 7, i32 1, i1 false)
15   %4 = getelementptr inbounds %struct.foo* %foobie, i64 0, i32 2
16   store i32 20, i32* %4, align 4
17   ret i32 undef
18
19 ; Check that the memcpy is removed.
20 ; CHECK-LABEL: @test1(
21 ; CHECK-NOT: call void @llvm.memcpy
22 }
23
24 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
25