Skip to content

Commit 537cfc0

Browse files
committedDec 4, 2018
[asan] Reduce binary size by using unnamed private aliases
Summary: --asan-use-private-alias increases binary sizes by 10% or more. Most of this space was long names of aliases and new symbols. These symbols are not needed for the ODC check at all. Reviewers: eugenis Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D55146 llvm-svn: 348221
1 parent bce2086 commit 537cfc0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

‎llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ class AddressSanitizerModule : public ModulePass {
746746
ClRecover : Recover;
747747
this->CompileKernel = ClEnableKasan.getNumOccurrences() > 0 ?
748748
ClEnableKasan : CompileKernel;
749-
}
749+
}
750750

751751
bool runOnModule(Module &M) override;
752752
StringRef getPassName() const override { return "AddressSanitizerModule"; }
@@ -2176,8 +2176,8 @@ bool AddressSanitizerModule::InstrumentGlobals(IRBuilder<> &IRB, Module &M, bool
21762176
if (CanUsePrivateAliases && ClUsePrivateAliasForGlobals) {
21772177
// Create local alias for NewGlobal to avoid crash on ODR between
21782178
// instrumented and non-instrumented libraries.
2179-
auto *GA = GlobalAlias::create(GlobalValue::InternalLinkage,
2180-
NameForGlobal + M.getName(), NewGlobal);
2179+
auto *GA =
2180+
GlobalAlias::create(GlobalValue::PrivateLinkage, "", NewGlobal);
21812181

21822182
// With local aliases, we need to provide another externally visible
21832183
// symbol __odr_asan_XXX to detect ODR violation.

‎llvm/test/Instrumentation/AddressSanitizer/local_alias.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ target triple = "x86_64-unknown-linux-gnu"
77

88
; Check that we generate internal alias and odr indicator symbols for global to be protected.
99
; CHECK: @__odr_asan_gen_a = internal global i8 0, align 1
10-
; CHECK: @"a<stdin>" = internal alias { [2 x i32], [56 x i8] }, { [2 x i32], [56 x i8] }* @a
10+
; CHECK: @0 = private alias { [2 x i32], [56 x i8] }, { [2 x i32], [56 x i8] }* @a
1111

1212
; Function Attrs: nounwind sanitize_address uwtable
1313
define i32 @foo(i32 %M) #0 {

0 commit comments

Comments
 (0)
Please sign in to comment.