1 ; 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 16 define void @foo() { 17 ; CHECK-LABEL: foo 18 entry: 19 ; CHECK: store i32 42, i32* @a 20 store i32 42, i32* @a 21 ret void 22 } 23 define i32 @bar() { 24 ; CHECK-LABEL: bar 25 entry: 26 ; CHECK: %val = load i32, i32* @a 27 %val = load i32, i32* @a 28 ret i32 %val 29 } 30 31 define i32 @baz() { 32 ; CHECK-LABEL: baz 33 entry: 34 ; CHECK: %val = load i32, i32* @b 35 %val = load i32, i32* @b 36 ret i32 %val 37 } 38