Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 1 | ; RUN: opt -globalopt -instcombine %s -S -o - | FileCheck %s |
| 2 | |
| 3 | ; Static constructor should have been optimized out |
| 4 | ; CHECK: i32 @main |
| 5 | ; CHECK-NEXT: ret i32 69905 |
| 6 | ; CHECK-NOT: _GLOBAL__sub_I_main.cpp |
| 7 | |
| 8 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 9 | target triple = "x86_64-pc-linux-gnu" |
| 10 | |
| 11 | %struct.S = type { %struct.A* } |
| 12 | %struct.A = type { i64, i64 } |
| 13 | |
| 14 | @s = internal local_unnamed_addr global %struct.S zeroinitializer, align 8 |
| 15 | @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_main.cpp, i8* null }] |
| 16 | @gA = available_externally dso_local local_unnamed_addr global %struct.A* inttoptr (i64 69905 to %struct.A*), align 8 |
| 17 | |
| 18 | define dso_local i32 @main() local_unnamed_addr { |
| 19 | %1 = load i64, i64* bitcast (%struct.S* @s to i64*), align 8 |
| 20 | %2 = trunc i64 %1 to i32 |
| 21 | ret i32 %2 |
| 22 | } |
| 23 | |
| 24 | define internal void @_GLOBAL__sub_I_main.cpp() section ".text.startup" { |
| 25 | %1 = load i64, i64* bitcast (%struct.A** @gA to i64*), align 8 |
| 26 | store i64 %1, i64* bitcast (%struct.S* @s to i64*), align 8 |
| 27 | ret void |
| 28 | } |