Skip to content

Commit 387c656

Browse files
authored
Merge pull request #18774 from vedantk/instrprof-tsan
2 parents dd8b37e + c76494b commit 387c656

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/IRGen/IRGen.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,13 @@ void swift::performLLVMOptimizations(IRGenOptions &Opts, llvm::Module *Module,
262262
TargetMachine->getTargetIRAnalysis()));
263263

264264
// If we're generating a profile, add the lowering pass now.
265-
if (Opts.GenerateProfile)
266-
ModulePasses.add(createInstrProfilingLegacyPass());
265+
if (Opts.GenerateProfile) {
266+
// TODO: Surface the option to emit atomic profile counter increments at
267+
// the driver level.
268+
InstrProfOptions Options;
269+
Options.Atomic = bool(Opts.Sanitizers & SanitizerKind::Thread);
270+
ModulePasses.add(createInstrProfilingLegacyPass(Options));
271+
}
267272

268273
PMBuilder.populateModulePassManager(ModulePasses);
269274

test/Profiler/instrprof_tsan.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %target-swift-frontend -emit-ir -profile-generate -sanitize=thread %s | %FileCheck %s
2+
3+
// CHECK: define {{.*}}empty
4+
// CHECK-NOT: load{{.*}}empty
5+
// CHECK: ret void
6+
func empty() {
7+
}
8+
9+
empty()

0 commit comments

Comments
 (0)