Skip to content

Commit a3e3bf2

Browse files
authored
Merge pull request #14204 from vedantk/fix-profiling-import
2 parents 1b53061 + 5670324 commit a3e3bf2

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/IRGen/GenBuiltin.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ void irgen::emitBuiltinCall(IRGenFunction &IGF, const BuiltinInfo &Builtin,
198198
// At that stage, the function name GV used by the profiling pass is hidden.
199199
// Fix the intrinsic call here by pointing it to the correct GV.
200200
if (IID == llvm::Intrinsic::instrprof_increment) {
201+
// If we import profiling intrinsics from a swift module but profiling is
202+
// not enabled, ignore the increment.
203+
if (!IGF.getSILModule().getOptions().GenerateProfile)
204+
return;
205+
201206
// Extract the PGO function name.
202207
auto *NameGEP = cast<llvm::User>(args.claimNext());
203208
auto *NameGV = dyn_cast<llvm::GlobalVariable>(NameGEP->stripPointerCasts());

test/IRGen/coverage_ignored.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -profile-generate -emit-sil -o %t.sil
2+
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir -o - | %FileCheck %s
3+
4+
// CHECK-NOT: llvm.instrprof
5+
// CHECK-NOT: profc
6+
func foo() {}
7+
foo()

0 commit comments

Comments
 (0)