[PATCH] Added address sanitizer instrumentation for MOV and MOVAPS inline assembly instructions.

Evgeniy Stepanov eugenis at google.com
Wed Feb 26 05:08:05 PST 2014



================
Comment at: lib/Target/X86/AsmParser/X86AddressSanitizer.cpp:238
@@ +237,3 @@
+X86AddressSanitizer* X86AddressSanitizerFactory::Create(MCSubtargetInfo &STI) {
+  if (ClInstrumentInlineAssembly) {
+    if ((STI.getFeatureBits() & X86::Mode32Bit) != 0)
----------------
Check sanitize_address function attribute as well.

Not sure what to do if it's not inline assembly - do we have any function attributes then? Probably not. Need a way to pass the active sanitizer, if any, down here.


================
Comment at: lib/Target/X86/AsmParser/X86AsmParser.cpp:59
@@ -56,2 +58,3 @@
   ParseInstructionInfo *InstInfo;
+  OwningPtr<X86AddressSanitizer> Asan;
 private:
----------------
Ideally, this file should never mention AddressSanitizer. There are other sanitizers that we would to choose based on the function attributes. Perhaps rename the base class to something like X86Instrumentation or X86(Asm|MC)Instrumentation.

================
Comment at: lib/Target/X86/AsmParser/X86AsmParser.cpp:2278
@@ -2272,3 +2277,3 @@
 
   // FIXME: Ideally, we would only attempt suffix matches for things which are
   // valid prefixes, and we could just infer the right unambiguous
----------------
Do we need to handle instructions on this path, as well?
I.e. in case of Match_InvalidOperand and Match_MnemonicFail, after some extra matching is done.

================
Comment at: lib/Target/X86/AsmParser/X86AddressSanitizer.cpp:207
@@ +206,3 @@
+  // Set %rsp below current red zone (128 bytes wide)
+  EmitInstruction(Out, MCInstBuilder(X86::SUB64ri32)
+                           .addReg(X86::RSP)
----------------
Does stack unwinding in ASan reports still work? I'm pretty sure you need to describe stack manipulations with CFI directives. OK to leave a FIXME for now.

================
Comment at: test/Instrumentation/AddressSanitizer/X86/load.ll:1
@@ +1,2 @@
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+sse2 -asan-instrument-inline-assembly | FileCheck %s
+
----------------
Please add tests for
- no instrumentation (i.e. compilation without -sanitize=address)
- instrumentation of a .S source



http://llvm-reviews.chandlerc.com/D2881



More information about the llvm-commits mailing list