Skip to content
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
4 changes: 3 additions & 1 deletion include/swift/SIL/SILFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "swift/Basic/ProfileCounter.h"
#include "swift/SIL/SILBasicBlock.h"
#include "swift/SIL/SILDebugScope.h"
#include "swift/SIL/SILDeclRef.h"
#include "swift/SIL/SILLinkage.h"
#include "swift/SIL/SILPrintContext.h"
#include "llvm/ADT/StringMap.h"
Expand Down Expand Up @@ -362,7 +363,8 @@ class SILFunction
Profiler = InheritedProfiler;
}

void createProfiler(ASTNode Root, ForDefinition_t forDefinition);
void createProfiler(ASTNode Root, SILDeclRef forDecl,
ForDefinition_t forDefinition);

void discardProfiler() { Profiler = nullptr; }

Expand Down
10 changes: 7 additions & 3 deletions include/swift/SIL/SILProfiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class SILProfiler : public SILAllocated<SILProfiler> {

ASTNode Root;

SILDeclRef forDecl;

bool EmitCoverageMapping;

SILCoverageMap *CovMap = nullptr;
Expand All @@ -61,12 +63,14 @@ class SILProfiler : public SILAllocated<SILProfiler> {

std::vector<std::tuple<std::string, uint64_t, std::string>> CoverageData;

SILProfiler(SILModule &M, ASTNode Root, bool EmitCoverageMapping)
: M(M), Root(Root), EmitCoverageMapping(EmitCoverageMapping) {}
SILProfiler(SILModule &M, ASTNode Root, SILDeclRef forDecl,
bool EmitCoverageMapping)
: M(M), Root(Root), forDecl(forDecl),
EmitCoverageMapping(EmitCoverageMapping) {}

public:
static SILProfiler *create(SILModule &M, ForDefinition_t forDefinition,
ASTNode N);
ASTNode N, SILDeclRef forDecl);

/// Check if the function is set up for profiling.
bool hasRegionCounters() const { return NumRegionCounters != 0; }
Expand Down
5 changes: 3 additions & 2 deletions lib/SIL/SILFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,10 @@ SILFunction::~SILFunction() {
"Function cannot be deleted while function_ref's still exist");
}

void SILFunction::createProfiler(ASTNode Root, ForDefinition_t forDefinition) {
void SILFunction::createProfiler(ASTNode Root, SILDeclRef forDecl,
ForDefinition_t forDefinition) {
assert(!Profiler && "Function already has a profiler");
Profiler = SILProfiler::create(Module, forDefinition, Root);
Profiler = SILProfiler::create(Module, forDefinition, Root, forDecl);
}

bool SILFunction::hasForeignBody() const {
Expand Down
Loading