xref: /llvm-project/llvm/test/Transforms/GlobalOpt/dead-store-status.ll (revision d586bd5ca231a6022f439d4c6e43cfeeb53eb1d6)
1; RUN: opt < %s -passes=globalopt -S | FileCheck %s
2
3; When removing the store to @global in @foo, the pass would incorrectly return
4; false. This was caught by the pass return status check that is hidden under
5; EXPENSIVE_CHECKS.
6
7; CHECK: @global = internal unnamed_addr global ptr null, align 1
8
9; CHECK-LABEL: @foo
10; CHECK-NEXT: entry:
11; CHECK-NEXT: ret i16 undef
12
13@global = internal unnamed_addr global ptr null, align 1
14
15; Function Attrs: nofree noinline norecurse nounwind writeonly
16define i16 @foo(i16 %c) local_unnamed_addr #0 {
17entry:
18  %local1.addr = alloca i16, align 1
19  store ptr %local1.addr, ptr @global, align 1
20  ret i16 undef
21}
22
23; Function Attrs: noinline nounwind writeonly
24define i16 @bar() local_unnamed_addr #1 {
25entry:
26  %local2 = alloca [1 x i16], align 1
27  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %local2)
28  store ptr %local2, ptr @global, align 1
29  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %local2)
30  ret i16 undef
31}
32
33; Function Attrs: argmemonly nounwind willreturn
34declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
35
36; Function Attrs: argmemonly nounwind willreturn
37declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
38
39attributes #0 = { nofree noinline norecurse nounwind writeonly }
40attributes #1 = { noinline nounwind writeonly }
41attributes #2 = { argmemonly nounwind willreturn }
42