1 ; RUN: opt < %s -globalopt -S | FileCheck %s
3 ; Test the evaluation of a load via a bitcast and a store via a GEP.
4 ; Check that globals are constant folded to the correct value.
6 ; CHECK: @u = dso_local local_unnamed_addr global %union.A { i8* inttoptr (i64 12345 to i8*) }, align 8
7 ; CHECK: @l = dso_local local_unnamed_addr global i64 12345, align 8
9 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
10 target triple = "x86_64-unknown-linux-gnu"
12 %union.A = type { i8* }
14 $_ZN1AC2Ex = comdat any
16 @u = dso_local global %union.A zeroinitializer, align 8
17 @l = dso_local global i64 0, align 8
18 @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_test.cpp, i8* null }]
20 define internal void @__cxx_global_var_init() section ".text.startup" {
21 call void @_ZN1AC2Ex(%union.A* @u, i64 12345)
25 define linkonce_odr dso_local void @_ZN1AC2Ex(%union.A* %this, i64 %ll) unnamed_addr comdat align 2 {
26 %l = inttoptr i64 %ll to i8*
27 %p = getelementptr inbounds %union.A, %union.A* %this, i64 0, i32 0
32 define internal void @__cxx_global_var_init.1() section ".text.startup" {
33 %1 = load i64, i64* bitcast (%union.A* @u to i64*), align 8
34 store i64 %1, i64* @l, align 8
38 define internal void @_GLOBAL__sub_I_test.cpp() section ".text.startup" {
39 call void @__cxx_global_var_init()
40 call void @__cxx_global_var_init.1()