brintos

brintos / llvm-project-archived public Read only

0
0
Text · 944 B · 13de91f Raw
29 lines · plain
1; This test lets globalopt split the global struct and array into different2; values. This used to crash, because globalopt forgot to put the new var in the3; same address space as the old one.4 5; RUN: opt < %s -passes=globalopt -S | FileCheck %s6 7; Check that the new global values still have their address space8; CHECK: addrspace(1) global9; CHECK: addrspace(1) global10 11@struct = internal addrspace(1) global { i32, i32 } zeroinitializer12@array = internal addrspace(1) global [ 2 x i32 ] zeroinitializer 13 14define i32 @foo() {15  %A = load i32, ptr addrspace(1) @struct16  %B = load i32, ptr addrspace(1) @array17  ; Use the loaded values, so they won't get removed completely18  %R = add i32 %A, %B19  ret i32 %R20}21 22; We put stores in a different function, so that the global variables won't get23; optimized away completely.24define void @bar(i32 %R) {25  store i32 %R, ptr addrspace(1) @array26  store i32 %R, ptr addrspace(1) @struct27  ret void28}29