• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %s -basicaa -dse -S | FileCheck %s
2
3%t = type { i32 }
4
5@g = global i32 42
6
7define void @test1(%t* noalias %pp) {
8  %p = getelementptr inbounds %t* %pp, i32 0, i32 0
9
10  store i32 1, i32* %p; <-- This is dead
11  %x = load i32* inttoptr (i32 12345 to i32*)
12  store i32 %x, i32* %p
13  ret void
14; CHECK: define void @test1
15; CHECK: store
16; CHECK-NOT: store
17; CHECK: ret void
18}
19
20define void @test3() {
21  store i32 1, i32* @g; <-- This is dead.
22  store i32 42, i32* @g
23  ret void
24; CHECK: define void @test3
25; CHECK: store
26; CHECK-NOT: store
27; CHECK: ret void
28}
29
30define void @test4(i32* %p) {
31  store i32 1, i32* %p
32  %x = load i32* @g; <-- %p and @g could alias
33  store i32 %x, i32* %p
34  ret void
35; CHECK: define void @test4
36; CHECK: store
37; CHECK: store
38; CHECK: ret void
39}
40