c6c2e13e33e12c3e24f1d578426a6cd4a7236ec2
[oota-llvm.git] / test / Transforms / FunctionAttrs / 2008-10-04-LocalMemory.ll
1 ; RUN: opt < %s -functionattrs -S | FileCheck %s
2
3 %struct.X = type { i32*, i32* }
4
5 declare i32 @g(i32*) readnone
6
7 define i32 @f() {
8 ; CHECK: @f() readnone
9         %x = alloca i32         ; <i32*> [#uses=2]
10         store i32 0, i32* %x
11         %y = call i32 @g(i32* %x)               ; <i32> [#uses=1]
12         ret i32 %y
13 }
14
15 define i32 @foo() nounwind {
16 ; CHECK: @foo() nounwind readonly
17 entry:
18   %y = alloca %struct.X                           ; <%struct.X*> [#uses=2]
19   %x = alloca %struct.X                           ; <%struct.X*> [#uses=2]
20   %j = alloca i32                                 ; <i32*> [#uses=2]
21   %i = alloca i32                                 ; <i32*> [#uses=2]
22   %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
23   store i32 0, i32* %i, align 4
24   store i32 1, i32* %j, align 4
25   %0 = getelementptr inbounds %struct.X* %y, i32 0, i32 0 ; <i32**> [#uses=1]
26   store i32* %i, i32** %0, align 8
27   %1 = getelementptr inbounds %struct.X* %x, i32 0, i32 1 ; <i32**> [#uses=1]
28   store i32* %j, i32** %1, align 8
29   %x1 = bitcast %struct.X* %x to i8*              ; <i8*> [#uses=2]
30   %y2 = bitcast %struct.X* %y to i8*              ; <i8*> [#uses=1]
31   call void @llvm.memcpy.i64(i8* %x1, i8* %y2, i64 8, i32 1)
32   %2 = bitcast i8* %x1 to i32**                   ; <i32**> [#uses=1]
33   %3 = load i32** %2, align 8                     ; <i32*> [#uses=1]
34   %4 = load i32* %3, align 4                      ; <i32> [#uses=1]
35   br label %return
36
37 return:                                           ; preds = %entry
38   ret i32 %4
39 }
40
41 define i32 @t(i32 %a, i32 %b, i32 %c) nounwind {
42 ; CHECK: @t(i32 %a, i32 %b, i32 %c) nounwind readnone
43 entry:
44   %a.addr = alloca i32                            ; <i32*> [#uses=3]
45   %c.addr = alloca i32                            ; <i32*> [#uses=2]
46   store i32 %a, i32* %a.addr
47   store i32 %c, i32* %c.addr
48   %tmp = load i32* %a.addr                        ; <i32> [#uses=1]
49   %tobool = icmp ne i32 %tmp, 0                   ; <i1> [#uses=1]
50   br i1 %tobool, label %if.then, label %if.else
51
52 if.then:                                          ; preds = %entry
53   br label %if.end
54
55 if.else:                                          ; preds = %entry
56   br label %if.end
57
58 if.end:                                           ; preds = %if.else, %if.then
59   %p.0 = phi i32* [ %a.addr, %if.then ], [ %c.addr, %if.else ] ; <i32*> [#uses=1]
60   %tmp2 = load i32* %p.0                          ; <i32> [#uses=1]
61   ret i32 %tmp2
62 }
63
64 declare void @llvm.memcpy.i64(i8* nocapture, i8* nocapture, i64, i32) nounwind