1 ; RUN: opt < %s -passes=globalopt -S | FileCheck %s
3 ; Test the evaluation of a store and a load via a bitcast, and check
4 ; that globals are constant folded to the correct value.
6 ; CHECK: @u = dso_local local_unnamed_addr global %union.A { ptr inttoptr (i64 12345 to ptr) }, align 8
7 ; CHECK: @l = dso_local local_unnamed_addr global i64 12345, align 8
12 ; A(long long ll) : l(ll) {}
19 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
20 target triple = "x86_64-unknown-linux-gnu"
22 %union.A = type { ptr }
24 $_ZN1AC2Ex = comdat any
26 @u = dso_local global %union.A zeroinitializer, align 8
27 @l = dso_local global i64 0, align 8
28 @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_test.cpp, ptr null }]
30 define internal void @__cxx_global_var_init() section ".text.startup" {
31 call void @_ZN1AC2Ex(ptr @u, i64 12345)
35 define linkonce_odr dso_local void @_ZN1AC2Ex(ptr %this, i64 %ll) unnamed_addr comdat align 2 {
36 store i64 %ll, ptr %this, align 8
40 define internal void @__cxx_global_var_init.1() section ".text.startup" {
41 %1 = load i64, ptr @u, align 8
42 store i64 %1, ptr @l, align 8
46 define internal void @_GLOBAL__sub_I_test.cpp() section ".text.startup" {
47 call void @__cxx_global_var_init()
48 call void @__cxx_global_var_init.1()