1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -passes=newgvn -disable-output < %s
6 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"
7 target triple = "x86_64-apple-darwin10.0"
9 define ptr @test1(ptr %name, i32 %namelen, ptr %o, i32 %expected_type) nounwind ssp {
11 br i1 undef, label %if.end13, label %while.body.preheader
14 if.end13: ; preds = %if.then6
15 br label %while.body.preheader
17 while.body.preheader: ; preds = %if.end13, %if.end
20 while.body: ; preds = %while.body.backedge, %while.body.preheader
21 %o.addr.0 = phi ptr [ undef, %while.body.preheader ], [ %o.addr.0.be, %while.body.backedge ] ; <ptr> [#uses=2]
22 br i1 false, label %return.loopexit, label %lor.lhs.false
24 lor.lhs.false: ; preds = %while.body
25 %tmp22 = load i32, ptr %o.addr.0 ; <i32> [#uses=0]
26 br i1 undef, label %land.lhs.true24, label %if.end31
28 land.lhs.true24: ; preds = %lor.lhs.false
29 %call28 = call ptr @parse_object(ptr undef) nounwind ; <ptr> [#uses=0]
30 br i1 undef, label %return.loopexit, label %if.end31
32 if.end31: ; preds = %land.lhs.true24, %lor.lhs.false
33 br i1 undef, label %return.loopexit, label %if.end41
35 if.end41: ; preds = %if.end31
36 %tmp45 = load i32, ptr %o.addr.0 ; <i32> [#uses=0]
37 br i1 undef, label %if.then50, label %if.else
39 if.then50: ; preds = %if.end41
40 %tmp53 = load ptr, ptr undef ; <ptr> [#uses=1]
41 br label %while.body.backedge
43 if.else: ; preds = %if.end41
44 br i1 undef, label %if.then62, label %if.else67
46 if.then62: ; preds = %if.else
47 br label %while.body.backedge
49 while.body.backedge: ; preds = %if.then62, %if.then50
50 %o.addr.0.be = phi ptr [ %tmp53, %if.then50 ], [ undef, %if.then62 ] ; <ptr> [#uses=1]
53 if.else67: ; preds = %if.else
56 return.loopexit: ; preds = %if.end31, %land.lhs.true24, %while.body
60 declare ptr @parse_object(ptr)
67 %struct.attribute_spec = type { ptr, i32, i32, i8, i8, i8 }
69 @attribute_tables = external global [4 x ptr] ; <ptr> [#uses=2]
71 define void @test2() nounwind {
75 bb69.i: ; preds = %bb57.i.preheader
76 %tmp4 = getelementptr inbounds [4 x ptr], ptr @attribute_tables, i32 0, i32 undef ; <ptr> [#uses=1]
77 %tmp3 = load ptr, ptr %tmp4, align 4 ; <ptr> [#uses=1]
80 bb65.i: ; preds = %bb65.i.preheader, %bb64.i
81 %storemerge6.i = phi i32 [ 1, %bb64.i ], [ 0, %bb69.i ] ; <i32> [#uses=3]
82 %scevgep14 = getelementptr inbounds %struct.attribute_spec, ptr %tmp3, i32 %storemerge6.i, i32 0 ; <ptr> [#uses=1]
83 %tmp2 = load ptr, ptr %scevgep14, align 4 ; <ptr> [#uses=0]
84 %tmp = load ptr, ptr %tmp4, align 4 ; <ptr> [#uses=1]
85 %scevgep1516 = getelementptr inbounds %struct.attribute_spec, ptr %tmp, i32 %storemerge6.i, i32 0 ; <ptr> [#uses=0]
99 @g = external global i64, align 8
101 define ptr @test3() {
103 %tmp18.i = load ptr, ptr undef
104 br i1 undef, label %do.body36.i, label %if.then21.i
110 %ivar38.i = load i64, ptr @g
111 %add.ptr39.sum.i = add i64 %ivar38.i, 8
112 %tmp40.i = getelementptr inbounds i8, ptr %tmp18.i, i64 %add.ptr39.sum.i
113 %tmp41.i = load i64, ptr %tmp40.i
114 br i1 undef, label %if.then48.i, label %do.body57.i
117 %call54.i = call i32 @foo2()
118 br label %do.body57.i
121 %tmp58.i = load ptr, ptr undef
122 %ivar59.i = load i64, ptr @g
123 %add.ptr65.sum.i = add i64 %ivar59.i, 8
124 %tmp66.i = getelementptr inbounds i8, ptr %tmp58.i, i64 %add.ptr65.sum.i
125 %tmp67.i = load i64, ptr %tmp66.i
133 define i32 @test4() {
138 %P2 = getelementptr i32, ptr %P2, i32 52
139 %Q2 = getelementptr i32, ptr %Q2, i32 52
141 %A = load i32, ptr %Q2
142 br i1 true, label %dead, label %dead2
150 define fastcc i8 @test5(ptr %P) nounwind {
152 %0 = load i8, ptr %P, align 2
154 %Q = getelementptr i8, ptr %P, i32 1
155 %1 = load i8, ptr %Q, align 1
160 ; Test that a GEP in an unreachable block with the following form doesn't crash
163 ; %x = gep %some.type %x, ...
165 %struct.type = type { i64, i32, i32 }
167 define fastcc void @func() nounwind uwtable ssp align 2 {
169 br label %reachable.bb
174 %gep.val = getelementptr inbounds %struct.type, ptr %gep.val, i64 1
175 br i1 undef, label %u2.bb, label %u1.bb
178 store i64 -1, ptr %gep.val, align 8
179 br label %unreachable.bb
182 %0 = load i32, ptr undef, align 4
183 %conv.i.i.i.i.i = zext i32 %0 to i64