Skip to content

Undo "Disable ASan in coroutine functions; it interferes with splitting." (3a4185c). #23951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions lib/IRGen/IRGenSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1218,12 +1218,8 @@ IRGenSILFunction::IRGenSILFunction(IRGenModule &IGM, SILFunction *f)
// Apply sanitizer attributes to the function.
// TODO: Check if the function is supposed to be excluded from ASan either by
// being in the external file or via annotations.
if (IGM.IRGen.Opts.Sanitizers & SanitizerKind::Address) {
// Disable ASan in coroutines; stack poisoning is not going to do
// reasonable things to the structural invariants.
if (!f->getLoweredFunctionType()->isCoroutine())
CurFn->addFnAttr(llvm::Attribute::SanitizeAddress);
}
if (IGM.IRGen.Opts.Sanitizers & SanitizerKind::Address)
CurFn->addFnAttr(llvm::Attribute::SanitizeAddress);
if (IGM.IRGen.Opts.Sanitizers & SanitizerKind::Thread) {
auto declContext = f->getDeclContext();
if (f->getLoweredFunctionType()->isCoroutine()) {
Expand Down
4 changes: 2 additions & 2 deletions test/IRGen/asan-attributes.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This test verifies that we add the function attributes used by ASan.

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

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

// ASAN: attributes [[COROUTINE_ATTRS]] =
// ASAN-NOT: sanitize_address
// ASAN-SAME: sanitize_address
// ASAN-SAME: }