mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Disable TSan in coroutine functions; it interferes with lowering.
Fixes rdar://47491307. I've filed rdar://47642395 to track re-enabling TSan in coroutines.
This commit is contained in:
@@ -1226,14 +1226,18 @@ IRGenSILFunction::IRGenSILFunction(IRGenModule &IGM, SILFunction *f)
|
||||
}
|
||||
if (IGM.IRGen.Opts.Sanitizers & SanitizerKind::Thread) {
|
||||
auto declContext = f->getDeclContext();
|
||||
if (declContext && isa<DestructorDecl>(declContext))
|
||||
if (f->getLoweredFunctionType()->isCoroutine()) {
|
||||
// Disable TSan in coroutines; the instrumentation currently interferes
|
||||
// with coroutine structural invariants.
|
||||
} else if (declContext && isa<DestructorDecl>(declContext)) {
|
||||
// Do not report races in deinit and anything called from it
|
||||
// because TSan does not observe synchronization between retain
|
||||
// count dropping to '0' and the object deinitialization.
|
||||
CurFn->addFnAttr("sanitize_thread_no_checking_at_run_time");
|
||||
else
|
||||
} else {
|
||||
CurFn->addFnAttr(llvm::Attribute::SanitizeThread);
|
||||
}
|
||||
}
|
||||
|
||||
// Disable inlining of coroutine functions until we split.
|
||||
if (f->getLoweredFunctionType()->isCoroutine()) {
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
// This test verifies that we add the function attributes used by TSan.
|
||||
|
||||
// RUN: %target-swift-frontend -emit-ir -sanitize=thread %s | %FileCheck %s -check-prefix=TSAN
|
||||
// RUN: %target-swift-frontend -emit-ir -disable-llvm-optzns -sanitize=thread %s | %FileCheck %s -check-prefix=TSAN
|
||||
|
||||
// TSan is currently only supported on 64 bit mac and simulators.
|
||||
// (We do not test the simulators here.)
|
||||
// REQUIRES: CPU=x86_64, OS=macosx
|
||||
|
||||
func test() {
|
||||
// TSAN: define {{.*}} @"$s4main4testyyF"() [[DEFAULT_ATTRS:#[0-9]+]]
|
||||
public func test() {
|
||||
}
|
||||
|
||||
// TSAN: Function Attrs: sanitize_thread
|
||||
// TSAN: define {{.*}} @"$s4main1xSivr"({{.*}}) [[COROUTINE_ATTRS:#[0-9]+]]
|
||||
public var x: Int {
|
||||
_read {
|
||||
yield 0
|
||||
}
|
||||
}
|
||||
|
||||
// TSAN: attributes [[DEFAULT_ATTRS]] =
|
||||
// TSAN-SAME: sanitize_thread
|
||||
// TSAN-SAME: }
|
||||
|
||||
// TSAN: attributes [[COROUTINE_ATTRS]] =
|
||||
// TSAN-NOT: sanitize_address
|
||||
// TSAN-SAME: }
|
||||
|
||||
Reference in New Issue
Block a user