• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -globalopt -S -o - < %s | FileCheck %s
2
3target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
4target triple = "x86_64-unknown-linux-gnu"
5
6declare {}* @llvm.invariant.start.p0i8(i64 %size, i8* nocapture %ptr)
7
8define void @test1(i8* %ptr) {
9  call {}* @llvm.invariant.start.p0i8(i64 4, i8* %ptr)
10  ret void
11}
12
13@object1 = global i32 0
14; CHECK: @object1 = constant i32 -1
15define void @ctor1() {
16  store i32 -1, i32* @object1
17  %A = bitcast i32* @object1 to i8*
18  call void @test1(i8* %A)
19  ret void
20}
21
22
23@object2 = global i32 0
24; CHECK: @object2 = global i32 0
25define void @ctor2() {
26  store i32 -1, i32* @object2
27  %A = bitcast i32* @object2 to i8*
28  %B = call {}* @llvm.invariant.start.p0i8(i64 4, i8* %A)
29  %C = bitcast {}* %B to i8*
30  ret void
31}
32
33
34@object3 = global i32 0
35; CHECK: @object3 = global i32 -1
36define void @ctor3() {
37  store i32 -1, i32* @object3
38  %A = bitcast i32* @object3 to i8*
39  call {}* @llvm.invariant.start.p0i8(i64 3, i8* %A)
40  ret void
41}
42
43
44@object4 = global i32 0
45; CHECK: @object4 = global i32 -1
46define void @ctor4() {
47  store i32 -1, i32* @object4
48  %A = bitcast i32* @object4 to i8*
49  call {}* @llvm.invariant.start.p0i8(i64 -1, i8* %A)
50  ret void
51}
52
53
54@llvm.global_ctors = appending constant
55  [4 x { i32, void ()* }]
56  [ { i32, void ()* } { i32 65535, void ()* @ctor1 },
57    { i32, void ()* } { i32 65535, void ()* @ctor2 },
58    { i32, void ()* } { i32 65535, void ()* @ctor3 },
59    { i32, void ()* } { i32 65535, void ()* @ctor4 } ]
60