Skip to content

Commit c82ba58

Browse files
authored
Undo "Disable ASan in coroutine functions; it interferes with splitting." (3a4185c). (#23951) (#24039)
This is no longer needed because we now make sure to run the coroutine lowering pass before ASan/TSan instrumentation passes.
1 parent 9740a31 commit c82ba58

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,12 +1218,8 @@ IRGenSILFunction::IRGenSILFunction(IRGenModule &IGM, SILFunction *f)
12181218
// Apply sanitizer attributes to the function.
12191219
// TODO: Check if the function is supposed to be excluded from ASan either by
12201220
// being in the external file or via annotations.
1221-
if (IGM.IRGen.Opts.Sanitizers & SanitizerKind::Address) {
1222-
// Disable ASan in coroutines; stack poisoning is not going to do
1223-
// reasonable things to the structural invariants.
1224-
if (!f->getLoweredFunctionType()->isCoroutine())
1225-
CurFn->addFnAttr(llvm::Attribute::SanitizeAddress);
1226-
}
1221+
if (IGM.IRGen.Opts.Sanitizers & SanitizerKind::Address)
1222+
CurFn->addFnAttr(llvm::Attribute::SanitizeAddress);
12271223
if (IGM.IRGen.Opts.Sanitizers & SanitizerKind::Thread) {
12281224
auto declContext = f->getDeclContext();
12291225
if (f->getLoweredFunctionType()->isCoroutine()) {

test/IRGen/asan-attributes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This test verifies that we add the function attributes used by ASan.
22

3-
// RUN: %target-swift-frontend -emit-ir -disable-llvm-optzns -sanitize=address %s | %FileCheck %s -check-prefix=ASAN
3+
// RUN: %target-swift-frontend -emit-ir -sanitize=address %s | %FileCheck %s -check-prefix=ASAN
44

55
// ASAN: define {{.*}} @"$s4main4testyyF"() [[DEFAULT_ATTRS:#[0-9]+]]
66
public func test() {
@@ -18,5 +18,5 @@ public var x: Int {
1818
// ASAN-SAME: }
1919

2020
// ASAN: attributes [[COROUTINE_ATTRS]] =
21-
// ASAN-NOT: sanitize_address
21+
// ASAN-SAME: sanitize_address
2222
// ASAN-SAME: }

0 commit comments

Comments
 (0)