[llvm-branch-commits] [llvm-branch] r295376 - Merging r295215:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Feb 16 13:15:37 PST 2017


Author: hans
Date: Thu Feb 16 15:15:37 2017
New Revision: 295376

URL: http://llvm.org/viewvc/llvm-project?rev=295376&view=rev
Log:
Merging r295215:
------------------------------------------------------------------------
r295215 | arnolds | 2017-02-15 10:57:06 -0800 (Wed, 15 Feb 2017) | 11 lines

ThreadSanitizer: 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/ThreadSanitizer.cpp
    llvm/branches/release_40/test/Instrumentation/ThreadSanitizer/tsan_basic.ll

Propchange: llvm/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 16 15:15:37 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
+/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

Modified: llvm/branches/release_40/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Transforms/Instrumentation/ThreadSanitizer.cpp?rev=295376&r1=295375&r2=295376&view=diff
==============================================================================
--- llvm/branches/release_40/lib/Transforms/Instrumentation/ThreadSanitizer.cpp (original)
+++ llvm/branches/release_40/lib/Transforms/Instrumentation/ThreadSanitizer.cpp Thu Feb 16 15:15:37 2017
@@ -488,6 +488,13 @@ bool ThreadSanitizer::instrumentLoadOrSt
   Value *Addr = IsWrite
       ? cast<StoreInst>(I)->getPointerOperand()
       : cast<LoadInst>(I)->getPointerOperand();
+
+  // 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 (Addr->isSwiftError())
+    return false;
+
   int Idx = getMemoryAccessFuncIndex(Addr, DL);
   if (Idx < 0)
     return false;

Modified: llvm/branches/release_40/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/test/Instrumentation/ThreadSanitizer/tsan_basic.ll?rev=295376&r1=295375&r2=295376&view=diff
==============================================================================
--- llvm/branches/release_40/test/Instrumentation/ThreadSanitizer/tsan_basic.ll (original)
+++ llvm/branches/release_40/test/Instrumentation/ThreadSanitizer/tsan_basic.ll Thu Feb 16 15:15:37 2017
@@ -54,5 +54,29 @@ entry:
 ; CHECK: ret void
 }
 
+; CHECK-LABEL: @SwiftError
+; CHECK-NOT: __tsan_read
+; CHECK-NOT: __tsan_write
+; CHECK: ret
+define void @SwiftError(i8** swifterror) sanitize_thread {
+  %swifterror_ptr_value = load i8*, i8** %0
+  store i8* null, i8** %0
+  %swifterror_addr = alloca swifterror i8*
+  %swifterror_ptr_value_2 = load i8*, i8** %swifterror_addr
+  store i8* null, i8** %swifterror_addr
+  ret void
+}
+
+; CHECK-LABEL: @SwiftErrorCall
+; CHECK-NOT: __tsan_read
+; CHECK-NOT: __tsan_write
+; CHECK: ret
+define void @SwiftErrorCall(i8** swifterror) sanitize_thread {
+  %swifterror_addr = alloca swifterror i8*
+  store i8* null, i8** %0
+  call void @SwiftError(i8** %0)
+  ret void
+}
+
 ; CHECK: define internal void @tsan.module_ctor()
 ; CHECK: call void @__tsan_init()




More information about the llvm-branch-commits mailing list