diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2016-06-14 21:01:22 +0000 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-06-14 21:01:22 +0000 |
| commit | 96efdd6107a06e762e2cd25eb41b053f946ac87a (patch) | |
| tree | 784c39f51cb5c4ec15071c7db559fb0b31e2f484 /llvm/test/tools | |
| parent | 1dc9fd3c4a260883b1559f7b92ad9156ecc2418c (diff) | |
| download | bcm5719-llvm-96efdd6107a06e762e2cd25eb41b053f946ac87a.tar.gz bcm5719-llvm-96efdd6107a06e762e2cd25eb41b053f946ac87a.zip | |
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
Diffstat (limited to 'llvm/test/tools')
| -rw-r--r-- | llvm/test/tools/gold/X86/coff.ll | 4 | ||||
| -rw-r--r-- | llvm/test/tools/gold/X86/emit-llvm.ll | 28 |
2 files changed, 25 insertions, 7 deletions
diff --git a/llvm/test/tools/gold/X86/coff.ll b/llvm/test/tools/gold/X86/coff.ll index 5d8a1c9da5f..7ab80707ba1 100644 --- a/llvm/test/tools/gold/X86/coff.ll +++ b/llvm/test/tools/gold/X86/coff.ll @@ -16,7 +16,7 @@ define hidden void @g() { ret void } -; CHECK: define internal void @h() { -define linkonce_odr void @h() { +; CHECK: define internal void @h() local_unnamed_addr { +define linkonce_odr void @h() local_unnamed_addr { ret void } diff --git a/llvm/test/tools/gold/X86/emit-llvm.ll b/llvm/test/tools/gold/X86/emit-llvm.ll index 4a6d5963cff..0a955088c40 100644 --- a/llvm/test/tools/gold/X86/emit-llvm.ll +++ b/llvm/test/tools/gold/X86/emit-llvm.ll @@ -25,6 +25,24 @@ target triple = "x86_64-unknown-linux-gnu" +; CHECK-DAG: @g1 = linkonce_odr constant i32 32 +@g1 = linkonce_odr constant i32 32 + +; CHECK-DAG: @g2 = internal local_unnamed_addr constant i32 32 +@g2 = linkonce_odr local_unnamed_addr constant i32 32 + +; CHECK-DAG: @g3 = internal unnamed_addr constant i32 32 +@g3 = linkonce_odr unnamed_addr constant i32 32 + +; CHECK-DAG: @g4 = linkonce_odr global i32 32 +@g4 = linkonce_odr global i32 32 + +; CHECK-DAG: @g5 = linkonce_odr local_unnamed_addr global i32 32 +@g5 = linkonce_odr local_unnamed_addr global i32 32 + +; CHECK-DAG: @g6 = internal unnamed_addr global i32 32 +@g6 = linkonce_odr unnamed_addr global i32 32 + @g7 = extern_weak global i32 ; CHECK-DAG: @g7 = extern_weak global i32 @@ -53,7 +71,7 @@ define void @f3() { ; CHECK-DAG: define internal void @f4() ; OPT2-NOT: @f4 -define linkonce_odr void @f4() { +define linkonce_odr void @f4() local_unnamed_addr { ret void } @@ -62,14 +80,14 @@ define linkonce_odr void @f4() { define linkonce_odr void @f5() { ret void } -@g5 = global void()* @f5 +@g9 = global void()* @f5 ; CHECK-DAG: define internal void @f6() unnamed_addr ; OPT-DAG: define internal void @f6() unnamed_addr define linkonce_odr void @f6() unnamed_addr { ret void } -@g6 = global void()* @f6 +@g10 = global void()* @f6 define i32* @f7() { ret i32* @g7 @@ -89,5 +107,5 @@ define i32* @f8() { ; API: f8 PREVAILING_DEF_IRONLY_EXP ; API: g7 UNDEF ; API: g8 UNDEF -; API: g5 PREVAILING_DEF_IRONLY_EXP -; API: g6 PREVAILING_DEF_IRONLY_EXP +; API: g9 PREVAILING_DEF_IRONLY_EXP +; API: g10 PREVAILING_DEF_IRONLY_EXP |

