1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00
llvm-mirror/test/Feature/OperandBundles/pr26510.ll
Peter Collingbourne 5dcb77e9fb IR: Introduce local_unnamed_addr attribute.
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
2016-06-14 21:01:22 +00:00

28 lines
856 B
LLVM

; RUN: opt -S -globals-aa -functionattrs < %s | FileCheck %s
; RUN: opt -S -O3 < %s | FileCheck %s
; Apart from checking for the direct cause of the bug, we also check
; if any problematic aliasing rules have accidentally snuck into -O3.
;
; Since the "abc" operand bundle is not a special operand bundle that
; LLVM knows about, all of the stores and loads in @test below have to
; stay.
declare void @foo() readnone
; CHECK-LABEL: define i8* @test(i8* %p)
; CHECK: %a = alloca i8*, align 8
; CHECK: store i8* %p, i8** %a, align 8
; CHECK: call void @foo() [ "abc"(i8** %a) ]
; CHECK: %reload = load i8*, i8** %a, align 8
; CHECK: ret i8* %reload
; CHECK: }
define i8* @test(i8* %p) {
%a = alloca i8*, align 8
store i8* %p, i8** %a, align 8
call void @foo() ["abc" (i8** %a)]
%reload = load i8*, i8** %a, align 8
ret i8* %reload
}