[llvm] r206734 - [asan] insert __asan_loadN/__asan_storeN as out-lined asan checks, llvm part

Kostya Serebryany kcc at google.com
Mon Apr 21 00:10:44 PDT 2014


Author: kcc
Date: Mon Apr 21 02:10:43 2014
New Revision: 206734

URL: http://llvm.org/viewvc/llvm-project?rev=206734&view=rev
Log:
[asan] insert __asan_loadN/__asan_storeN as out-lined asan checks, llvm part

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=206734&r1=206733&r2=206734&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Mon Apr 21 02:10:43 2014
@@ -365,7 +365,8 @@ struct AddressSanitizer : public Functio
   Function *AsanErrorCallback[2][kNumberOfAccessSizes];
   Function *AsanMemoryAccessCallback[2][kNumberOfAccessSizes];
   // This array is indexed by AccessIsWrite.
-  Function *AsanErrorCallbackSized[2];
+  Function *AsanErrorCallbackSized[2],
+           *AsanMemoryAccessCallbackSized[2];
   InlineAsm *EmptyAsm;
   SetOfDynamicallyInitializedGlobals DynamicallyInitializedGlobals;
 
@@ -824,8 +825,12 @@ void AddressSanitizer::instrumentAddress
   size_t AccessSizeIndex = TypeSizeToSizeIndex(TypeSize);
 
   if (UseCalls) {
-    IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][AccessSizeIndex],
-                   AddrLong);
+    if (SizeArgument)
+      IRB.CreateCall2(AsanMemoryAccessCallbackSized[IsWrite], AddrLong,
+                      SizeArgument);
+    else
+      IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][AccessSizeIndex],
+                     AddrLong);
     return;
   }
 
@@ -1149,6 +1154,13 @@ void AddressSanitizer::initializeCallbac
   AsanErrorCallbackSized[1] = checkInterfaceFunction(M.getOrInsertFunction(
               kAsanReportStoreN, IRB.getVoidTy(), IntptrTy, IntptrTy, NULL));
 
+  AsanMemoryAccessCallbackSized[0] = checkInterfaceFunction(
+      M.getOrInsertFunction(ClMemoryAccessCallbackPrefix + "loadN",
+                            IRB.getVoidTy(), IntptrTy, IntptrTy, NULL));
+  AsanMemoryAccessCallbackSized[1] = checkInterfaceFunction(
+      M.getOrInsertFunction(ClMemoryAccessCallbackPrefix + "storeN",
+                            IRB.getVoidTy(), IntptrTy, IntptrTy, NULL));
+
   AsanHandleNoReturnFunc = checkInterfaceFunction(M.getOrInsertFunction(
       kAsanHandleNoReturnName, IRB.getVoidTy(), NULL));
   AsanCovFunction = checkInterfaceFunction(M.getOrInsertFunction(





More information about the llvm-commits mailing list