Add support for global variables in an address space for llvm-c and ocaml.
[oota-llvm.git] / test / Transforms / GVN / 2008-02-26-MemCpySize.ll
1 ; RUN: opt < %s -gvn -dse -S | grep {call.*memcpy.*cell} | count 2
2 ; PR2099
3
4 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"
5 target triple = "i686-apple-darwin9"
6         %struct.s = type { [11 x i8], i32 }
7 @.str = internal constant [11 x i8] c"0123456789\00"            ; <[11 x i8]*> [#uses=1]
8 @cell = weak global %struct.s zeroinitializer           ; <%struct.s*> [#uses=2]
9
10 declare i32 @check(%struct.s* byval  %p) nounwind
11
12 declare i32 @strcmp(i8*, i8*) nounwind readonly 
13
14 define i32 @main() noreturn nounwind  {
15 entry:
16         %p = alloca %struct.s, align 8          ; <%struct.s*> [#uses=2]
17         store i32 99, i32* getelementptr (%struct.s* @cell, i32 0, i32 1), align 4
18         call void @llvm.memcpy.i32( i8* getelementptr (%struct.s* @cell, i32 0, i32 0, i32 0), i8* getelementptr ([11 x i8]* @.str, i32 0, i32 0), i32 11, i32 1 )
19         %tmp = getelementptr %struct.s* %p, i32 0, i32 0, i32 0         ; <i8*> [#uses=2]
20         call void @llvm.memcpy.i64( i8* %tmp, i8* getelementptr (%struct.s* @cell, i32 0, i32 0, i32 0), i64 16, i32 8 )
21         %tmp1.i = getelementptr %struct.s* %p, i32 0, i32 1             ; <i32*> [#uses=1]
22         %tmp2.i = load i32* %tmp1.i, align 4            ; <i32> [#uses=1]
23         %tmp3.i = icmp eq i32 %tmp2.i, 99               ; <i1> [#uses=1]
24         br i1 %tmp3.i, label %bb5.i, label %bb
25
26 bb5.i:          ; preds = %entry
27         %tmp91.i = call i32 @strcmp( i8* %tmp, i8* getelementptr ([11 x i8]* @.str, i32 0, i32 0) ) nounwind readonly           ; <i32> [#uses=1]
28         %tmp53 = icmp eq i32 %tmp91.i, 0                ; <i1> [#uses=1]
29         br i1 %tmp53, label %bb7, label %bb
30
31 bb:             ; preds = %bb5.i, %entry
32         call void @abort( ) noreturn nounwind 
33         unreachable
34
35 bb7:            ; preds = %bb5.i
36         call void @exit( i32 0 ) noreturn nounwind 
37         unreachable
38 }
39
40 declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) nounwind 
41
42 declare void @abort() noreturn nounwind 
43
44 declare void @exit(i32) noreturn nounwind 
45
46 declare void @llvm.memcpy.i64(i8*, i8*, i64, i32) nounwind