@@ -500,7 +500,7 @@ SILFunction *SILGenModule::getFunction(SILDeclRef constant,
500
500
if (auto *fd = constant.getFuncDecl ()) {
501
501
if (hasSILBody (fd)) {
502
502
// Set up the function for profiling instrumentation.
503
- F->createProfiler (fd);
503
+ F->createProfiler (fd, forDefinition );
504
504
profiledNode = fd->getBody (/* canSynthesize=*/ false );
505
505
}
506
506
}
@@ -519,7 +519,7 @@ SILFunction *SILGenModule::getFunction(SILDeclRef constant,
519
519
520
520
if (!profiledNode) {
521
521
if (auto *ce = dyn_cast<ClosureExpr>(ace)) {
522
- F->createProfiler (ce);
522
+ F->createProfiler (ce, forDefinition );
523
523
profiledNode = ce;
524
524
}
525
525
}
@@ -747,19 +747,23 @@ void SILGenModule::emitConstructor(ConstructorDecl *decl) {
747
747
748
748
SILDeclRef constant (decl);
749
749
750
- bool ForCoverageMapping = M.getOptions ().EmitProfileCoverageMapping ;
750
+ ForDefinition_t ForCoverageMapping = M.getOptions ().EmitProfileCoverageMapping
751
+ ? ForDefinition
752
+ : NotForDefinition;
751
753
752
754
if (decl->getDeclContext ()->getAsClassOrClassExtensionContext ()) {
753
755
// Class constructors have separate entry points for allocation and
754
756
// initialization.
755
- emitOrDelayFunction (*this , constant, [this ,constant,decl](SILFunction *f){
756
- preEmitFunction (constant, decl, f, decl);
757
- PrettyStackTraceSILFunction X (" silgen emitConstructor" , f);
758
- f->createProfiler (decl);
759
- SILGenFunction (*this , *f)
760
- .emitClassConstructorAllocator (decl);
761
- postEmitFunction (constant, f);
762
- }, /* forceEmission=*/ ForCoverageMapping);
757
+ emitOrDelayFunction (
758
+ *this , constant,
759
+ [this , constant, decl, ForCoverageMapping](SILFunction *f) {
760
+ preEmitFunction (constant, decl, f, decl);
761
+ PrettyStackTraceSILFunction X (" silgen emitConstructor" , f);
762
+ f->createProfiler (decl, ForCoverageMapping);
763
+ SILGenFunction (*this , *f).emitClassConstructorAllocator (decl);
764
+ postEmitFunction (constant, f);
765
+ },
766
+ /* forceEmission=*/ ForCoverageMapping);
763
767
764
768
// If this constructor was imported, we don't need the initializing
765
769
// constructor to be emitted.
@@ -775,13 +779,16 @@ void SILGenModule::emitConstructor(ConstructorDecl *decl) {
775
779
}
776
780
} else {
777
781
// Struct and enum constructors do everything in a single function.
778
- emitOrDelayFunction (*this , constant, [this ,constant,decl](SILFunction *f) {
779
- preEmitFunction (constant, decl, f, decl);
780
- PrettyStackTraceSILFunction X (" silgen emitConstructor" , f);
781
- f->createProfiler (decl);
782
- SILGenFunction (*this , *f).emitValueConstructor (decl);
783
- postEmitFunction (constant, f);
784
- }, /* forceEmission=*/ ForCoverageMapping);
782
+ emitOrDelayFunction (
783
+ *this , constant,
784
+ [this , constant, decl, ForCoverageMapping](SILFunction *f) {
785
+ preEmitFunction (constant, decl, f, decl);
786
+ PrettyStackTraceSILFunction X (" silgen emitConstructor" , f);
787
+ f->createProfiler (decl, ForCoverageMapping);
788
+ SILGenFunction (*this , *f).emitValueConstructor (decl);
789
+ postEmitFunction (constant, f);
790
+ },
791
+ /* forceEmission=*/ ForCoverageMapping);
785
792
}
786
793
}
787
794
@@ -865,7 +872,7 @@ void SILGenModule::emitObjCAllocatorDestructor(ClassDecl *cd,
865
872
SILFunction *f = getFunction (dealloc, ForDefinition);
866
873
preEmitFunction (dealloc, dd, f, dd);
867
874
PrettyStackTraceSILFunction X (" silgen emitDestructor -dealloc" , f);
868
- f->createProfiler (dd);
875
+ f->createProfiler (dd, ForDefinition );
869
876
SILGenFunction (*this , *f).emitObjCDestructor (dealloc);
870
877
postEmitFunction (dealloc, f);
871
878
}
@@ -935,7 +942,7 @@ void SILGenModule::emitDestructor(ClassDecl *cd, DestructorDecl *dd) {
935
942
SILFunction *f = getFunction (deallocator, ForDefinition);
936
943
preEmitFunction (deallocator, dd, f, dd);
937
944
PrettyStackTraceSILFunction X (" silgen emitDeallocatingDestructor" , f);
938
- f->createProfiler (dd);
945
+ f->createProfiler (dd, ForDefinition );
939
946
SILGenFunction (*this , *f).emitDeallocatingDestructor (dd);
940
947
f->setDebugScope (new (M) SILDebugScope (dd, f));
941
948
postEmitFunction (deallocator, f);
@@ -1303,7 +1310,7 @@ void SILGenModule::visitTopLevelCodeDecl(TopLevelCodeDecl *td) {
1303
1310
// A single SILFunction may be used to lower multiple top-level decls. When
1304
1311
// this happens, fresh profile counters must be assigned to the new decl.
1305
1312
TopLevelSGF->F .discardProfiler ();
1306
- TopLevelSGF->F .createProfiler (td);
1313
+ TopLevelSGF->F .createProfiler (td, ForDefinition );
1307
1314
1308
1315
TopLevelSGF->emitProfilerIncrement (td->getBody ());
1309
1316
0 commit comments