1 ; Test that llvm-reduce can remove uninteresting Global Variables as well as
2 ; their direct uses (which in turn are replaced with '0').
4 ; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=global-variables,global-initializers --test FileCheck --test-arg --check-prefixes=CHECK-ALL,CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
5 ; RUN: FileCheck --check-prefixes=CHECK-ALL,CHECK-FINAL --implicit-check-not=uninteresting %s < %t
7 $interesting5 = comdat any
9 ; CHECK-INTERESTINGNESS: @interesting = {{.*}}global i32{{.*}}, align 4
10 ; CHECK-INTERESTINGNESS: @interesting2 = global i32 0, align 4
11 ; CHECK-INTERESTINGNESS: @interesting3 = {{.*}}global i32{{.*}}, align 4
12 ; CHECK-INTERESTINGNESS: @interesting4 = {{.*}}constant i32{{.*}}, align 4
13 ; CHECK-INTERESTINGNESS: @interesting5 = {{.*}}global i32{{.*}}, align 4
15 ; CHECK-FINAL: @interesting = external global i32, align 4
16 ; CHECK-FINAL: @interesting2 = global i32 0, align 4
17 ; CHECK-FINAL: @interesting3 = external global i32, align 4
18 ; CHECK-FINAL: @interesting4 = external dso_local constant i32, align 4
19 ; CHECK-FINAL: @interesting5 = external global i32, align 4
20 @interesting = global i32 0, align 4
21 @interesting2 = global i32 0, align 4
22 @interesting3 = external global i32, align 4
23 @interesting4 = private constant i32 2, align 4
24 @interesting5 = global i32 2, align 4, comdat
26 @uninteresting = global i32 1, align 4
27 @uninteresting2 = external global i32, align 4
31 %0 = load i32, ptr @uninteresting, align 4
33 ; CHECK-INTERESTINGNESS: store i32 {{.*}}, ptr @interesting, align 4
34 ; CHECK-FINAL: store i32 %0, ptr @interesting, align 4
35 store i32 %0, ptr @interesting, align 4
37 ; CHECK-INTERESTINGNESS: store i32 {{.*}}, ptr @interesting3, align 4
38 ; CHECK-FINAL: store i32 %0, ptr @interesting3, align 4
39 store i32 %0, ptr @interesting3, align 4
41 ; CHECK-ALL: load i32, ptr @interesting, align 4
42 %1 = load i32, ptr @interesting, align 4
43 store i32 %1, ptr @uninteresting, align 4
45 ; CHECK-ALL: load i32, ptr @interesting3, align 4
46 %2 = load i32, ptr @interesting3, align 4
47 store i32 %2, ptr @uninteresting2, align 4
49 ; CHECK-ALL: store i32 5, ptr @interesting, align 4
50 store i32 5, ptr @interesting, align 4
52 ; CHECK-ALL: store i32 5, ptr @interesting3, align 4
53 store i32 5, ptr @interesting3, align 4