mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
5dcb77e9fb
If a local_unnamed_addr attribute is attached to a global, the address is known to be insignificant within the module. It is distinct from the existing unnamed_addr attribute in that it only describes a local property of the module rather than a global property of the symbol. This attribute is intended to be used by the code generator and LTO to allow the linker to decide whether the global needs to be in the symbol table. It is possible to exclude a global from the symbol table if three things are true: - This attribute is present on every instance of the global (which means that the normal rule that the global must have a unique address can be broken without being observable by the program by performing comparisons against the global's address) - The global has linkonce_odr linkage (which means that each linkage unit must have its own copy of the global if it requires one, and the copy in each linkage unit must be the same) - It is a constant or a function (which means that the program cannot observe that the unique-address rule has been broken by writing to the global) Although this attribute could in principle be computed from the module contents, LTO clients (i.e. linkers) will normally need to be able to compute this property as part of symbol resolution, and it would be inefficient to materialize every module just to compute it. See: http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160509/356401.html http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160516/356738.html for earlier discussion. Part of the fix for PR27553. Differential Revision: http://reviews.llvm.org/D20348 llvm-svn: 272709
67 lines
2.2 KiB
LLVM
67 lines
2.2 KiB
LLVM
; RUN: opt < %s -globalopt -S | FileCheck %s
|
|
|
|
@c = global i8 42
|
|
|
|
@i = internal global i8 42
|
|
; CHECK: @ia = internal global i8 42
|
|
@ia = internal alias i8, i8* @i
|
|
|
|
@llvm.used = appending global [3 x i8*] [i8* bitcast (void ()* @fa to i8*), i8* bitcast (void ()* @f to i8*), i8* @ca], section "llvm.metadata"
|
|
; CHECK-DAG: @llvm.used = appending global [3 x i8*] [i8* @ca, i8* bitcast (void ()* @f to i8*), i8* bitcast (void ()* @fa to i8*)], section "llvm.metadata"
|
|
|
|
@llvm.compiler.used = appending global [4 x i8*] [i8* bitcast (void ()* @fa3 to i8*), i8* bitcast (void ()* @fa to i8*), i8* @ia, i8* @i], section "llvm.metadata"
|
|
; CHECK-DAG: @llvm.compiler.used = appending global [2 x i8*] [i8* bitcast (void ()* @fa3 to i8*), i8* @ia], section "llvm.metadata"
|
|
|
|
@sameAsUsed = global [3 x i8*] [i8* bitcast (void ()* @fa to i8*), i8* bitcast (void ()* @f to i8*), i8* @ca]
|
|
; CHECK-DAG: @sameAsUsed = local_unnamed_addr global [3 x i8*] [i8* bitcast (void ()* @f to i8*), i8* bitcast (void ()* @f to i8*), i8* @c]
|
|
|
|
@other = global i32* bitcast (void ()* @fa to i32*)
|
|
; CHECK-DAG: @other = local_unnamed_addr global i32* bitcast (void ()* @f to i32*)
|
|
|
|
@fa = internal alias void (), void ()* @f
|
|
; CHECK: @fa = internal alias void (), void ()* @f
|
|
|
|
@fa2 = internal alias void (), void ()* @f
|
|
; CHECK-NOT: @fa2
|
|
|
|
@fa3 = internal alias void (), void ()* @f
|
|
; CHECK: @fa3
|
|
|
|
@ca = internal alias i8, i8* @c
|
|
; CHECK: @ca = internal alias i8, i8* @c
|
|
|
|
define void @f() {
|
|
ret void
|
|
}
|
|
|
|
define i8* @g() {
|
|
ret i8* bitcast (void ()* @fa to i8*);
|
|
}
|
|
|
|
define i8* @g2() {
|
|
ret i8* bitcast (void ()* @fa2 to i8*);
|
|
}
|
|
|
|
define i8* @h() {
|
|
ret i8* @ca
|
|
}
|
|
|
|
; Check that GlobalOpt doesn't try to resolve aliases with GEP operands.
|
|
|
|
%struct.S = type { i32, i32, i32 }
|
|
@s = global %struct.S { i32 1, i32 2, i32 3 }, align 4
|
|
|
|
@alias1 = alias i32, i32* getelementptr inbounds (%struct.S, %struct.S* @s, i64 0, i32 1)
|
|
@alias2 = alias i32, i32* getelementptr inbounds (%struct.S, %struct.S* @s, i64 0, i32 2)
|
|
|
|
; CHECK: load i32, i32* @alias1, align 4
|
|
; CHECK: load i32, i32* @alias2, align 4
|
|
|
|
define i32 @foo1() {
|
|
entry:
|
|
%0 = load i32, i32* @alias1, align 4
|
|
%1 = load i32, i32* @alias2, align 4
|
|
%add = add nsw i32 %1, %0
|
|
ret i32 %add
|
|
}
|