• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test to make sure llvm.invariant.start calls are not treated as clobbers.
2; RUN: opt < %s -basic-aa -dse -S | FileCheck %s
3
4declare {}* @llvm.invariant.start.p0i8(i64, i8* nocapture) nounwind readonly
5
6; We cannot remove the store 1 to %p.
7; FIXME: By the semantics of invariant.start, the store 3 to p is unreachable.
8define void @test(i8 *%p) {
9  store i8 1, i8* %p, align 4
10  %i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %p)
11  store i8 3, i8* %p, align 4
12  ret void
13; CHECK-LABEL: @test(
14; CHECK-NEXT: store i8 1, i8* %p, align 4
15; CHECK-NEXT: %i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %p)
16; CHECK-NEXT: store i8 3, i8* %p, align 4
17; CHECK-NEXT: ret void
18}
19
20; FIXME: We should be able to remove the first store to p, even though p and q
21; may alias.
22define void @test2(i8* %p, i8* %q) {
23  store i8 1, i8* %p, align 4
24  store i8 2, i8* %q, align 4
25  %i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %q)
26  store i8 3, i8* %p, align 4
27  ret void
28; CHECK-LABEL: @test2(
29; CHECK-NEXT: store i8 1, i8* %p, align 4
30; CHECK-NEXT: store i8 2, i8* %q, align 4
31; CHECK-NEXT: %i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %q)
32; CHECK-NEXT: store i8 3, i8* %p, align 4
33; CHECK-NEXT: ret void
34}
35