Skip to content

Commit 6e15311

Browse files
committed
---
yaml --- r: 344990 b: refs/heads/master c: 99c36f7 h: refs/heads/master
1 parent d3c2c5d commit 6e15311

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: da52325f89d652aac035922193b375d6d32a90d8
2+
refs/heads/master: 99c36f7c6249b5246ae44c6284c7d43ce60d5027
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/IRGen/IRGenSIL.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,8 +1243,12 @@ IRGenSILFunction::IRGenSILFunction(IRGenModule &IGM,
12431243
// Apply sanitizer attributes to the function.
12441244
// TODO: Check if the function is supposed to be excluded from ASan either by
12451245
// being in the external file or via annotations.
1246-
if (IGM.IRGen.Opts.Sanitizers & SanitizerKind::Address)
1247-
CurFn->addFnAttr(llvm::Attribute::SanitizeAddress);
1246+
if (IGM.IRGen.Opts.Sanitizers & SanitizerKind::Address) {
1247+
// Disable ASan in coroutines; stack poisoning is not going to do
1248+
// reasonable things to the structural invariants.
1249+
if (!f->getLoweredFunctionType()->isCoroutine())
1250+
CurFn->addFnAttr(llvm::Attribute::SanitizeAddress);
1251+
}
12481252
if (IGM.IRGen.Opts.Sanitizers & SanitizerKind::Thread) {
12491253
auto declContext = f->getDeclContext();
12501254
if (declContext && isa<DestructorDecl>(declContext))
Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
// This test verifies that we add the function attributes used by ASan.
22

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

5-
func test() {
5+
// ASAN: define {{.*}} @"$S4main4testyyF"() [[DEFAULT_ATTRS:#[0-9]+]]
6+
public func test() {
67
}
78

8-
// ASAN: Function Attrs: sanitize_address
9+
// ASAN: define {{.*}} @"$S4main1xSivr"({{.*}}) [[COROUTINE_ATTRS:#[0-9]+]]
10+
public var x: Int {
11+
_read {
12+
yield 0
13+
}
14+
}
15+
16+
// ASAN: attributes [[DEFAULT_ATTRS]] =
17+
// ASAN-SAME: sanitize_address
18+
// ASAN-SAME: }
19+
20+
// ASAN: attributes [[COROUTINE_ATTRS]] =
21+
// ASAN-NOT: sanitize_address
22+
// ASAN-SAME: }

0 commit comments

Comments
 (0)