Author: hans
Date: Thu Feb 16 15:17:54 2017
New Revision: 295377

URL: http://llvm.org/viewvc/llvm-project?rev=295377&view=rev
Log:
Merging r295230:
------------------------------------------------------------------------
r295230 | arnolds | 2017-02-15 12:43:43 -0800 (Wed, 15 Feb 2017) | 11 lines

AddressSanitizer: don't track swifterror memory addresses

They are register promoted by ISel and so it makes no sense to treat them as
memory.

Inserting calls to the thread sanitizer would also generate invalid IR.

You would hit:

"swifterror value can only be loaded and stored from, or as a swifterror
argument!"
------------------------------------------------------------------------

Modified:
    llvm/branches/release_40/   (props changed)
    llvm/branches/release_40/lib/Transforms/Instrumentation/AddressSanitizer.cpp
    llvm/branches/release_40/test/Instrumentation/AddressSanitizer/basic.ll

Propchange: llvm/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 16 15:17:54 2017
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,291858-291859,291863,291875,291909,291918,291966,291968,291979,292117,292133,292167,292169-292170,292242,292254-292255,292280,292323,292444,292467,292516,292583,292624-292625,292641,292651,292667,292711-292713,292758,292949,293017,293021,293025,293230,293259,293291,293293,293309,293345,293417,293522,293542,293629,293635,293658,293673,293727,293730,294003,294102,294129,294203,294267,294318,294348-294349,294357,294527,294551,294982,295018,295213,295215
+/llvm/trunk:155241,291858-291859,291863,291875,291909,291918,291966,291968,291979,292117,292133,292167,292169-292170,292242,292254-292255,292280,292323,292444,292467,292516,292583,292624-292625,292641,292651,292667,292711-292713,292758,292949,293017,293021,293025,293230,293259,293291,293293,293309,293345,293417,293522,293542,293629,293635,293658,293673,293727,293730,294003,294102,294129,294203,294267,294318,294348-294349,294357,294527,294551,294982,295018,295213,295215,295230

Modified: 
llvm/branches/release_40/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=295377&r1=295376&r2=295377&view=diff
==============================================================================
--- 
llvm/branches/release_40/lib/Transforms/Instrumentation/AddressSanitizer.cpp 
(original)
+++ 
llvm/branches/release_40/lib/Transforms/Instrumentation/AddressSanitizer.cpp 
Thu Feb 16 15:17:54 2017
@@ -1013,7 +1013,9 @@ bool AddressSanitizer::isInterestingAllo
        (!ClSkipPromotableAllocas || !isAllocaPromotable(&AI)) &&
        // inalloca allocas are not treated as static, and we don't want
        // dynamic alloca instrumentation for them as well.
-       !AI.isUsedWithInAlloca());
+       !AI.isUsedWithInAlloca() &&
+       // swifterror allocas are register promoted by ISel
+       !AI.isSwiftError());
 
   ProcessedAllocas[&AI] = IsInteresting;
   return IsInteresting;
@@ -1088,12 +1090,19 @@ Value *AddressSanitizer::isInterestingMe
     }
   }
 
-  // Do not instrument acesses from different address spaces; we cannot deal
-  // with them.
   if (PtrOperand) {
+    // Do not instrument acesses from different address spaces; we cannot deal
+    // with them.
     Type *PtrTy = cast<PointerType>(PtrOperand->getType()->getScalarType());
     if (PtrTy->getPointerAddressSpace() != 0)
       return nullptr;
+
+    // Ignore swifterror addresses.
+    // swifterror memory addresses are mem2reg promoted by instruction
+    // selection. As such they cannot have regular uses like an instrumentation
+    // function and it makes no sense to track them as memory.
+    if (PtrOperand->isSwiftError())
+      return nullptr;
   }
 
   // Treat memory accesses to promotable allocas as non-interesting since they

Modified: 
llvm/branches/release_40/test/Instrumentation/AddressSanitizer/basic.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/test/Instrumentation/AddressSanitizer/basic.ll?rev=295377&r1=295376&r2=295377&view=diff
==============================================================================
--- llvm/branches/release_40/test/Instrumentation/AddressSanitizer/basic.ll 
(original)
+++ llvm/branches/release_40/test/Instrumentation/AddressSanitizer/basic.ll Thu 
Feb 16 15:17:54 2017
@@ -170,6 +170,32 @@ define void @memintr_test(i8* %a, i8* %b
 ; CHECK: __asan_memcpy
 ; CHECK: ret void
 
+; CHECK-LABEL: @test_swifterror
+; CHECK-NOT: __asan_report_load
+; CHECK: ret void
+define void @test_swifterror(i8** swifterror) sanitize_address {
+  %swifterror_ptr_value = load i8*, i8** %0
+  ret void
+}
+
+; CHECK-LABEL: @test_swifterror_2
+; CHECK-NOT: __asan_report_store
+; CHECK: ret void
+define void @test_swifterror_2(i8** swifterror) sanitize_address {
+  store i8* null, i8** %0
+  ret void
+}
+
+; CHECK-LABEL: @test_swifterror_3
+; CHECK-NOT: __asan_report_store
+; CHECK: ret void
+define void @test_swifterror_3() sanitize_address {
+  %swifterror_addr = alloca swifterror i8*
+  store i8* null, i8** %swifterror_addr
+  call void @test_swifterror_2(i8** swifterror %swifterror_addr)
+  ret void
+}
+
 ; CHECK: define internal void @asan.module_ctor()
 ; CHECK: call void @__asan_init()
 


_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to