blob: c01ba10f49c969bb7f1b88845cd3bfa4917ce7f0 [file] [log] [blame]
Eric Christophercee313d2019-04-17 04:52:47 +00001; RUN: opt < %s -S -globalopt | FileCheck %s
2
3; This global is externally_initialized, which may modify the value between
4; it's static initializer and any code in this module being run, so the only
5; write to it cannot be merged into the static initialiser.
6; CHECK: @a = internal unnamed_addr externally_initialized global i32 undef
7@a = internal externally_initialized global i32 undef
8
9; This global is stored to by the external initialization, so cannot be
10; constant-propagated and removed, despite the fact that there are no writes
11; to it.
12; CHECK: @b = internal unnamed_addr externally_initialized global i32 undef
13@b = internal externally_initialized global i32 undef
14
15
16define void @foo() {
17; CHECK-LABEL: foo
18entry:
19; CHECK: store i32 42, i32* @a
20 store i32 42, i32* @a
21 ret void
22}
23define i32 @bar() {
24; CHECK-LABEL: bar
25entry:
26; CHECK: %val = load i32, i32* @a
27 %val = load i32, i32* @a
28 ret i32 %val
29}
30
31define i32 @baz() {
32; CHECK-LABEL: baz
33entry:
34; CHECK: %val = load i32, i32* @b
35 %val = load i32, i32* @b
36 ret i32 %val
37}