• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -global-merge -global-merge-max-offset=100 -S -o - %s | FileCheck %s
2
3target datalayout = "e-p:64:64"
4target triple = "x86_64-unknown-linux-gnu"
5
6; CHECK: @_MergedGlobals = private global <{ i32, i32 }> <{ i32 3, i32 3 }>, align 4
7
8@a = internal global i32 1
9
10@b = internal global i32 2
11
12@c = internal global i32 3
13
14@d = internal global i32 3
15
16@llvm.used = appending global [1 x i8*] [i8* bitcast (i32* @a to i8*)], section "llvm.metadata"
17@llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i32* @b to i8*)], section "llvm.metadata"
18
19define void @use() {
20  ; CHECK: load i32, i32* @a
21  %x = load i32, i32* @a
22  ; CHECK: load i32, i32* @b
23  %y = load i32, i32* @b
24  ; CHECK: load i32, i32* getelementptr inbounds (<{ i32, i32 }>, <{ i32, i32 }>* @_MergedGlobals, i32 0, i32 0)
25  %z1 = load i32, i32* @c
26  ; CHECK: load i32, i32* getelementptr inbounds (<{ i32, i32 }>, <{ i32, i32 }>* @_MergedGlobals, i32 0, i32 1)
27  %z2 = load i32, i32* @d
28  ret void
29}
30