[PATCH] D31912: [asan] Give global metadata private linkage.
Evgeniy Stepanov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 17:11:12 PDT 2017
eugenis created this revision.
Internal linkage preserves names like "__asan_global_foo" which may
account to 2% of unstripped binary size.
Repository:
rL LLVM
https://reviews.llvm.org/D31912
Files:
lib/Transforms/Instrumentation/AddressSanitizer.cpp
test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll
test/Instrumentation/AddressSanitizer/global_metadata_windows.ll
Index: test/Instrumentation/AddressSanitizer/global_metadata_windows.ll
===================================================================
--- test/Instrumentation/AddressSanitizer/global_metadata_windows.ll
+++ test/Instrumentation/AddressSanitizer/global_metadata_windows.ll
@@ -13,7 +13,7 @@
; CHECK: $dead_global = comdat noduplicates
; CHECK: @dead_global = local_unnamed_addr global { i32, [60 x i8] } { i32 42, [60 x i8] zeroinitializer }, comdat, align 32
-; CHECK: @__asan_global_dead_global = internal global { {{.*}} }, section ".ASAN$GL", comdat($dead_global), align 64
+; CHECK: @__asan_global_dead_global = private global { {{.*}} }, section ".ASAN$GL", comdat($dead_global), align 64
@dead_global = local_unnamed_addr global i32 42, align 4
@mystr = linkonce_odr unnamed_addr constant [5 x i8] c"main\00", comdat, align 1
Index: test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll
===================================================================
--- test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll
+++ test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll
@@ -16,10 +16,10 @@
; Find the metadata for @global:
-; CHECK: [[METADATA:@.+]] = internal global {{.*}} @global {{.*}} section "__DATA,__asan_globals,regular"
+; CHECK: [[METADATA:@.+]] = private global {{.*}} @global {{.*}} section "__DATA,__asan_globals,regular"
; Find the liveness binder for @global and its metadata:
-; CHECK: @__asan_binder_global = internal global {{.*}} @global {{.*}} [[METADATA]] {{.*}} section "__DATA,__asan_liveness,regular,live_support"
+; CHECK: @__asan_binder_global = private global {{.*}} @global {{.*}} [[METADATA]] {{.*}} section "__DATA,__asan_liveness,regular,live_support"
; The binder has to be inserted to llvm.compiler.used to avoid being stripped
; during LTO.
Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1627,7 +1627,7 @@
StringRef OriginalName) {
GlobalVariable *Metadata =
new GlobalVariable(M, Initializer->getType(), false,
- GlobalVariable::InternalLinkage, Initializer,
+ GlobalVariable::PrivateLinkage, Initializer,
Twine("__asan_global_") +
GlobalValue::getRealLinkageName(OriginalName));
Metadata->setSection(getGlobalMetadataSection());
@@ -1691,7 +1691,7 @@
LivenessTy, Initializer->getAggregateElement(0u),
ConstantExpr::getPointerCast(Metadata, IntptrTy), nullptr);
GlobalVariable *Liveness = new GlobalVariable(
- M, LivenessTy, false, GlobalVariable::InternalLinkage, LivenessBinder,
+ M, LivenessTy, false, GlobalVariable::PrivateLinkage, LivenessBinder,
Twine("__asan_binder_") + G->getName());
Liveness->setSection("__DATA,__asan_liveness,regular,live_support");
LivenessGlobals[i] = Liveness;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31912.94758.patch
Type: text/x-patch
Size: 3109 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170411/4b46aca6/attachment.bin>
More information about the llvm-commits
mailing list