[asan] Add a flag to control asm instrumentation.
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Wed, 7 May 2014 07:54:11 +0000 (07:54 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Wed, 7 May 2014 07:54:11 +0000 (07:54 +0000)
With this change, asm instrumentation is disabled by default.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208167 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp
test/Instrumentation/AddressSanitizer/X86/asm_attr.ll
test/Instrumentation/AddressSanitizer/X86/asm_mov.ll
test/Instrumentation/AddressSanitizer/X86/asm_mov.s
test/Instrumentation/AddressSanitizer/X86/asm_swap_intel.s

index c8b541f3af611dc361ee5d8eb7ddd619a7c09480..95e4ccccb9d20a84728c58bab77890a46d5b1b5e 100644 (file)
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSubtargetInfo.h"
 #include "llvm/MC/MCTargetOptions.h"
+#include "llvm/Support/CommandLine.h"
 
 namespace llvm {
 namespace {
 
+static cl::opt<bool> ClAsanInstrumentAssembly(
+    "asan-instrument-assembly",
+    cl::desc("instrument assembly with AddressSanitizer checks"), cl::Hidden,
+    cl::init(false));
+
 bool IsStackReg(unsigned Reg) {
   return Reg == X86::RSP || Reg == X86::ESP || Reg == X86::SP;
 }
@@ -212,7 +218,8 @@ CreateX86AsmInstrumentation(const MCTargetOptions &MCOptions,
                             const MCContext &Ctx, const MCSubtargetInfo &STI) {
   Triple T(STI.getTargetTriple());
   const bool hasCompilerRTSupport = T.isOSLinux();
-  if (hasCompilerRTSupport && MCOptions.SanitizeAddress) {
+  if (ClAsanInstrumentAssembly && hasCompilerRTSupport &&
+      MCOptions.SanitizeAddress) {
     if ((STI.getFeatureBits() & X86::Mode32Bit) != 0)
       return new X86AddressSanitizer32(STI);
     if ((STI.getFeatureBits() & X86::Mode64Bit) != 0)
index 5beebb41f353fa9ff1ac099239574be8740ce330..b83a7e90f363c0b9a63db93b2a4e8a081269ca47 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+sse2 -asm-instrumentation=address | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+sse2 -asm-instrumentation=address -asan-instrument-assembly | FileCheck %s
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
index edb4784a58bcadf8421d7bd89c927628f8ec6ad2..94265c2cc74436d073a1cd44605345ac33171d6a 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+sse2 -asm-instrumentation=address | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+sse2 -asm-instrumentation=address -asan-instrument-assembly | FileCheck %s
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
index 5ae380df717a1e776de60956b7dcbcac03424099..a12c6cc5c18fe1b5f4d7148232e9980a71c0fad0 100644 (file)
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s -triple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+sse2 -asm-instrumentation=address | FileCheck %s
+# RUN: llvm-mc %s -triple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+sse2 -asm-instrumentation=address -asan-instrument-assembly | FileCheck %s
 
        .text
        .globl  mov1b
index 4144bf5e565346e4b7b15ea581e964470f1ad9eb..b56224ce0d80c8d0591ae37fe2b4903d0738e358 100644 (file)
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s -x86-asm-syntax=intel -triple=x86_64-unknown-linux-gnu -asm-instrumentation=address | FileCheck %s
+# RUN: llvm-mc %s -x86-asm-syntax=intel -triple=x86_64-unknown-linux-gnu -asm-instrumentation=address -asan-instrument-assembly | FileCheck %s
 
        .text
        .globl  swap