mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Sema] Add counter to track number of constraints considered by each edge contraction attempt
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "ConstraintGraph.h"
|
||||
#include "ConstraintGraphScope.h"
|
||||
#include "ConstraintSystem.h"
|
||||
#include "swift/Basic/Statistic.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/SaveAndRestore.h"
|
||||
#include <algorithm>
|
||||
@@ -27,6 +28,8 @@
|
||||
using namespace swift;
|
||||
using namespace constraints;
|
||||
|
||||
#define DEBUG_TYPE "ConstraintGraph"
|
||||
|
||||
#pragma mark Graph construction/destruction
|
||||
|
||||
ConstraintGraph::ConstraintGraph(ConstraintSystem &cs) : CS(cs) { }
|
||||
@@ -650,7 +653,9 @@ static bool shouldContractEdge(ConstraintKind kind) {
|
||||
|
||||
bool ConstraintGraph::contractEdges() {
|
||||
SmallVector<Constraint *, 16> constraints;
|
||||
CS.findConstraints(constraints, [](const Constraint &constraint) {
|
||||
CS.findConstraints(constraints, [&](const Constraint &constraint) {
|
||||
// Track how many constraints did contraction algorithm iterated over.
|
||||
incrementConstraintsPerContractionCounter();
|
||||
return shouldContractEdge(constraint.getKind());
|
||||
});
|
||||
|
||||
@@ -767,6 +772,14 @@ void ConstraintGraph::optimize() {
|
||||
while (contractEdges()) {}
|
||||
}
|
||||
|
||||
void ConstraintGraph::incrementConstraintsPerContractionCounter() {
|
||||
SWIFT_FUNC_STAT;
|
||||
auto &context = CS.getASTContext();
|
||||
if (context.Stats)
|
||||
context.Stats->getFrontendCounters()
|
||||
.NumConstraintsConsideredForEdgeContraction++;
|
||||
}
|
||||
|
||||
#pragma mark Debugging output
|
||||
|
||||
void ConstraintGraphNode::print(llvm::raw_ostream &out, unsigned indent) {
|
||||
|
||||
Reference in New Issue
Block a user