llvm.org GIT mirror llvm / 0ef546e
Make instcombine's DSE respect loads as well as stores. It is not safe to delete the first store in: store x -> p load p store y -> p This is for PR2297. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50859 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
2 changed file(s) with 26 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
1042510425 }
1042610426
1042710427 // Don't skip over loads or things that can modify memory.
10428 if (BBI->mayWriteToMemory())
10428 if (BBI->mayWriteToMemory() || BBI->mayReadFromMemory())
1042910429 break;
1043010430 }
1043110431
0 ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {store i8} | count 3
1 ; PR2297
2 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"
3 target triple = "i386-apple-darwin8"
4
5 define i32 @a() nounwind {
6 entry:
7 %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
8 %tmp1 = call i8* @malloc( i32 10 ) nounwind ; [#uses=5]
9 %tmp3 = getelementptr i8* %tmp1, i32 1 ; [#uses=1]
10 store i8 0, i8* %tmp3, align 1
11 %tmp5 = getelementptr i8* %tmp1, i32 0 ; [#uses=1]
12 store i8 1, i8* %tmp5, align 1
13 %tmp7 = call i32 @strlen( i8* %tmp1 ) nounwind readonly ; [#uses=1]
14 %tmp9 = getelementptr i8* %tmp1, i32 0 ; [#uses=1]
15 store i8 0, i8* %tmp9, align 1
16 %tmp11 = call i32 (...)* @b( i8* %tmp1 ) nounwind ; [#uses=0]
17 ret i32 %tmp7
18 }
19
20 declare i8* @malloc(i32) nounwind
21
22 declare i32 @strlen(i8*) nounwind readonly
23
24 declare i32 @b(...)