<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Hans and Kostya,<div class=""><br class=""></div><div class="">And another one … Can we merge this into the 4.0 branch?</div><div class=""><br class=""></div>This affects only the swift calling convention and swifterror so should be reasonably safe.<div class=""><br class=""></div><div class="">Thank you!</div><div class=""><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">Begin forwarded message:</div><br class="Apple-interchange-newline"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">From: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">Arnold Schwaighofer via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>><br class=""></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">Subject: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class=""><b class="">[llvm] r295230 - AddressSanitizer: don't track swifterror memory addresses</b><br class=""></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">Date: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">February 15, 2017 at 12:43:43 PM PST<br class=""></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">To: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class=""><a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class=""></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class=""><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">Reply-To: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">Arnold Schwaighofer <<a href="mailto:aschwaighofer@apple.com" class="">aschwaighofer@apple.com</a>><br class=""></span></div><br class=""><div class=""><div class="">Author: arnolds<br class="">Date: Wed Feb 15 14:43:43 2017<br class="">New Revision: 295230<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=295230&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=295230&view=rev</a><br class="">Log:<br class="">AddressSanitizer: don't track swifterror memory addresses<br class=""><br class="">They are register promoted by ISel and so it makes no sense to treat them as<br class="">memory.<br class=""><br class="">Inserting calls to the thread sanitizer would also generate invalid IR.<br class=""><br class="">You would hit:<br class=""><br class="">"swifterror value can only be loaded and stored from, or as a swifterror<br class="">argument!"<br class=""><br class="">Modified:<br class="">    llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp<br class="">    llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll<br class=""><br class="">Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=295230&r1=295229&r2=295230&view=diff" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=295230&r1=295229&r2=295230&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)<br class="">+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Wed Feb 15 14:43:43 2017<br class="">@@ -1013,7 +1013,9 @@ bool AddressSanitizer::isInterestingAllo<br class="">        (!ClSkipPromotableAllocas || !isAllocaPromotable(&AI)) &&<br class="">        // inalloca allocas are not treated as static, and we don't want<br class="">        // dynamic alloca instrumentation for them as well.<br class="">-       !AI.isUsedWithInAlloca());<br class="">+       !AI.isUsedWithInAlloca() &&<br class="">+       // swifterror allocas are register promoted by ISel<br class="">+       !AI.isSwiftError());<br class=""><br class="">   ProcessedAllocas[&AI] = IsInteresting;<br class="">   return IsInteresting;<br class="">@@ -1088,12 +1090,19 @@ Value *AddressSanitizer::isInterestingMe<br class="">     }<br class="">   }<br class=""><br class="">-  // Do not instrument acesses from different address spaces; we cannot deal<br class="">-  // with them.<br class="">   if (PtrOperand) {<br class="">+    // Do not instrument acesses from different address spaces; we cannot deal<br class="">+    // with them.<br class="">     Type *PtrTy = cast<PointerType>(PtrOperand->getType()->getScalarType());<br class="">     if (PtrTy->getPointerAddressSpace() != 0)<br class="">       return nullptr;<br class="">+<br class="">+    // Ignore swifterror addresses.<br class="">+    // swifterror memory addresses are mem2reg promoted by instruction<br class="">+    // selection. As such they cannot have regular uses like an instrumentation<br class="">+    // function and it makes no sense to track them as memory.<br class="">+    if (PtrOperand->isSwiftError())<br class="">+      return nullptr;<br class="">   }<br class=""><br class="">   // Treat memory accesses to promotable allocas as non-interesting since they<br class=""><br class="">Modified: llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll?rev=295230&r1=295229&r2=295230&view=diff" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll?rev=295230&r1=295229&r2=295230&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll (original)<br class="">+++ llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll Wed Feb 15 14:43:43 2017<br class="">@@ -170,6 +170,32 @@ define void @memintr_test(i8* %a, i8* %b<br class=""> ; CHECK: __asan_memcpy<br class=""> ; CHECK: ret void<br class=""><br class="">+; CHECK-LABEL: @test_swifterror<br class="">+; CHECK-NOT: __asan_report_load<br class="">+; CHECK: ret void<br class="">+define void @test_swifterror(i8** swifterror) sanitize_address {<br class="">+  %swifterror_ptr_value = load i8*, i8** %0<br class="">+  ret void<br class="">+}<br class="">+<br class="">+; CHECK-LABEL: @test_swifterror_2<br class="">+; CHECK-NOT: __asan_report_store<br class="">+; CHECK: ret void<br class="">+define void @test_swifterror_2(i8** swifterror) sanitize_address {<br class="">+  store i8* null, i8** %0<br class="">+  ret void<br class="">+}<br class="">+<br class="">+; CHECK-LABEL: @test_swifterror_3<br class="">+; CHECK-NOT: __asan_report_store<br class="">+; CHECK: ret void<br class="">+define void @test_swifterror_3() sanitize_address {<br class="">+  %swifterror_addr = alloca swifterror i8*<br class="">+  store i8* null, i8** %swifterror_addr<br class="">+  call void @test_swifterror_2(i8** swifterror %swifterror_addr)<br class="">+  ret void<br class="">+}<br class="">+<br class=""> ; CHECK: define internal void @asan.module_ctor()<br class=""> ; CHECK: call void @__asan_init()<br class=""><br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits<br class=""></div></div></blockquote></div><br class=""></div></div></body></html>