[llvm] r348316 - [asan] Split -asan-use-private-alias to -asan-use-odr-indicator
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 4 15:17:41 PST 2018
Author: vitalybuka
Date: Tue Dec 4 15:17:41 2018
New Revision: 348316
URL: http://llvm.org/viewvc/llvm-project?rev=348316&view=rev
Log:
[asan] Split -asan-use-private-alias to -asan-use-odr-indicator
Reviewers: eugenis, m.ostapenko, ygribov
Subscribers: mehdi_amini, kubamracek, hiraditya, steven_wu, dexonsmith, llvm-commits
Differential Revision: https://reviews.llvm.org/D55156
Modified:
llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/trunk/test/Instrumentation/AddressSanitizer/local_alias.ll
Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=348316&r1=348315&r2=348316&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Tue Dec 4 15:17:41 2018
@@ -344,10 +344,14 @@ static cl::opt<uint32_t> ClForceExperime
cl::init(0));
static cl::opt<bool>
- ClUsePrivateAliasForGlobals("asan-use-private-alias",
- cl::desc("Use private aliases for global"
- " variables"),
- cl::Hidden, cl::init(false));
+ ClUsePrivateAlias("asan-use-private-alias",
+ cl::desc("Use private aliases for global variables"),
+ cl::Hidden, cl::init(false));
+
+static cl::opt<bool>
+ ClUseOdrIndicator("asan-use-odr-indicator",
+ cl::desc("Use odr indicators to improve ODR reporting"),
+ cl::Hidden, cl::init(false));
static cl::opt<bool>
ClUseGlobalsGC("asan-globals-live-support",
@@ -2173,12 +2177,14 @@ bool AddressSanitizerModule::InstrumentG
bool CanUsePrivateAliases =
TargetTriple.isOSBinFormatELF() || TargetTriple.isOSBinFormatMachO() ||
TargetTriple.isOSBinFormatWasm();
- if (CanUsePrivateAliases && ClUsePrivateAliasForGlobals) {
+ if (CanUsePrivateAliases && ClUsePrivateAlias) {
// Create local alias for NewGlobal to avoid crash on ODR between
// instrumented and non-instrumented libraries.
- auto *GA =
+ InstrumentedGlobal =
GlobalAlias::create(GlobalValue::PrivateLinkage, "", NewGlobal);
+ }
+ if (ClUseOdrIndicator) {
// With local aliases, we need to provide another externally visible
// symbol __odr_asan_XXX to detect ODR violation.
auto *ODRIndicatorSym =
@@ -2192,7 +2198,6 @@ bool AddressSanitizerModule::InstrumentG
ODRIndicatorSym->setDLLStorageClass(NewGlobal->getDLLStorageClass());
ODRIndicatorSym->setAlignment(1);
ODRIndicator = ODRIndicatorSym;
- InstrumentedGlobal = GA;
}
Constant *Initializer = ConstantStruct::get(
Modified: llvm/trunk/test/Instrumentation/AddressSanitizer/local_alias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/local_alias.ll?rev=348316&r1=348315&r2=348316&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/AddressSanitizer/local_alias.ll (original)
+++ llvm/trunk/test/Instrumentation/AddressSanitizer/local_alias.ll Tue Dec 4 15:17:41 2018
@@ -1,4 +1,7 @@
-; RUN: opt < %s -asan -asan-module -asan-use-private-alias=1 -S | FileCheck %s
+; RUN: opt < %s -asan -asan-module -S | FileCheck %s --check-prefixes=CHECK-NOALIAS,CHECK-NOINDICATOR
+; RUN: opt < %s -asan -asan-module -asan-use-private-alias=1 -S | FileCheck %s --check-prefixes=CHECK-ALIAS,CHECK-NOINDICATOR
+; RUN: opt < %s -asan -asan-module -asan-use-odr-indicator=1 -S | FileCheck %s --check-prefixes=CHECK-INDICATOR,CHECK-NOALIAS
+; RUN: opt < %s -asan -asan-module -asan-use-private-alias=1 -asan-use-odr-indicator=1 -S | FileCheck %s --check-prefixes=CHECK-ALIAS,CHECK-INDICATOR
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@@ -6,8 +9,10 @@ target triple = "x86_64-unknown-linux-gn
@a = internal global [2 x i32] zeroinitializer, align 4
; Check that we generate internal alias and odr indicator symbols for global to be protected.
-; CHECK: @__odr_asan_gen_a = internal global i8 0, align 1
-; CHECK: @0 = private alias { [2 x i32], [56 x i8] }, { [2 x i32], [56 x i8] }* @a
+; CHECK-NOINDICATOR-NOT: __odr_asan_gen_a
+; CHECK-NOALIAS-NOT: private alias
+; CHECK-INDICATOR: @__odr_asan_gen_a = internal global i8 0, align 1
+; CHECK-ALIAS: @0 = private alias { [2 x i32], [56 x i8] }, { [2 x i32], [56 x i8] }* @a
; Function Attrs: nounwind sanitize_address uwtable
define i32 @foo(i32 %M) #0 {
More information about the llvm-commits
mailing list