mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
format
This commit is contained in:
@@ -43,8 +43,8 @@ class CoarseGrainedDependencyGraphImpl {
|
||||
public:
|
||||
/// Possible dependency kinds.
|
||||
///
|
||||
/// Clients of CoarseGrainedDependencyGraph should have no reason to use this type.
|
||||
/// It is only used in the implementation.
|
||||
/// Clients of CoarseGrainedDependencyGraph should have no reason to use this
|
||||
/// type. It is only used in the implementation.
|
||||
enum class DependencyKind : uint8_t;
|
||||
|
||||
/// Describes the result of loading a dependency file for a particular node.
|
||||
@@ -62,7 +62,8 @@ public:
|
||||
AffectsDownstream
|
||||
};
|
||||
|
||||
/// The non-templated implementation of CoarseGrainedDependencyGraph::MarkTracer.
|
||||
/// The non-templated implementation of
|
||||
/// CoarseGrainedDependencyGraph::MarkTracer.
|
||||
///
|
||||
/// \see CoarseGrainedDependencyGraph::MarkTracer
|
||||
class MarkTracerImpl {
|
||||
@@ -71,6 +72,7 @@ public:
|
||||
UnifiedStatsReporter *Stats;
|
||||
|
||||
friend class CoarseGrainedDependencyGraphImpl;
|
||||
|
||||
protected:
|
||||
explicit MarkTracerImpl(UnifiedStatsReporter *Stats);
|
||||
~MarkTracerImpl();
|
||||
@@ -210,7 +212,8 @@ class CoarseGrainedDependencyGraph : public CoarseGrainedDependencyGraphImpl {
|
||||
}
|
||||
|
||||
public:
|
||||
/// Traces the graph traversal performed in CoarseGrainedDependencyGraph::markTransitive.
|
||||
/// Traces the graph traversal performed in
|
||||
/// CoarseGrainedDependencyGraph::markTransitive.
|
||||
///
|
||||
/// This is intended to be a debugging aid.
|
||||
class MarkTracer : public MarkTracerImpl {
|
||||
@@ -240,8 +243,8 @@ public:
|
||||
/// call site can polymorphically call \ref
|
||||
/// fine_grained_dependencies::ModuleDepGraph::loadFromPath
|
||||
LoadResult loadFromPath(T node, StringRef path, DiagnosticEngine &) {
|
||||
return CoarseGrainedDependencyGraphImpl::loadFromPath(Traits::getAsVoidPointer(node),
|
||||
path);
|
||||
return CoarseGrainedDependencyGraphImpl::loadFromPath(
|
||||
Traits::getAsVoidPointer(node), path);
|
||||
}
|
||||
|
||||
/// Load "depends" and "provides" data for \p node from a plain string.
|
||||
@@ -250,16 +253,16 @@ public:
|
||||
///
|
||||
/// \sa loadFromPath
|
||||
LoadResult loadFromString(T node, StringRef data) {
|
||||
return CoarseGrainedDependencyGraphImpl::loadFromString(Traits::getAsVoidPointer(node),
|
||||
data);
|
||||
return CoarseGrainedDependencyGraphImpl::loadFromString(
|
||||
Traits::getAsVoidPointer(node), data);
|
||||
}
|
||||
|
||||
/// Adds \p node to the dependency graph without any connections.
|
||||
///
|
||||
/// This can be used for new nodes that may be updated later.
|
||||
void addIndependentNode(T node) {
|
||||
return
|
||||
CoarseGrainedDependencyGraphImpl::addIndependentNode(Traits::getAsVoidPointer(node));
|
||||
return CoarseGrainedDependencyGraphImpl::addIndependentNode(
|
||||
Traits::getAsVoidPointer(node));
|
||||
}
|
||||
|
||||
/// Marks \p node and all nodes that depend on \p node, and places any nodes
|
||||
@@ -287,9 +290,8 @@ public:
|
||||
void markTransitive(SmallVector<T, N> &visited, T node,
|
||||
MarkTracer *tracer = nullptr) {
|
||||
SmallVector<const void *, N> rawMarked;
|
||||
CoarseGrainedDependencyGraphImpl::markTransitive(rawMarked,
|
||||
Traits::getAsVoidPointer(node),
|
||||
tracer);
|
||||
CoarseGrainedDependencyGraphImpl::markTransitive(
|
||||
rawMarked, Traits::getAsVoidPointer(node), tracer);
|
||||
// FIXME: How can we avoid this copy?
|
||||
copyBack(visited, rawMarked);
|
||||
}
|
||||
@@ -297,7 +299,8 @@ public:
|
||||
template <unsigned N>
|
||||
void markExternal(SmallVector<T, N> &visited, StringRef externalDependency) {
|
||||
SmallVector<const void *, N> rawMarked;
|
||||
CoarseGrainedDependencyGraphImpl::markExternal(rawMarked, externalDependency);
|
||||
CoarseGrainedDependencyGraphImpl::markExternal(rawMarked,
|
||||
externalDependency);
|
||||
// FIXME: How can we avoid this copy?
|
||||
copyBack(visited, rawMarked);
|
||||
}
|
||||
@@ -308,13 +311,14 @@ public:
|
||||
///
|
||||
/// \sa #markTransitive
|
||||
bool markIntransitive(T node) {
|
||||
return
|
||||
CoarseGrainedDependencyGraphImpl::markIntransitive(Traits::getAsVoidPointer(node));
|
||||
return CoarseGrainedDependencyGraphImpl::markIntransitive(
|
||||
Traits::getAsVoidPointer(node));
|
||||
}
|
||||
|
||||
/// Returns true if \p node has been marked (directly or transitively).
|
||||
bool isMarked(T node) const {
|
||||
return CoarseGrainedDependencyGraphImpl::isMarked(Traits::getAsVoidPointer(node));
|
||||
return CoarseGrainedDependencyGraphImpl::isMarked(
|
||||
Traits::getAsVoidPointer(node));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -110,7 +110,8 @@ public:
|
||||
class CoarseGrainedDependencyGraphImpl {
|
||||
public:
|
||||
/// Use the status quo LoadResult for now.
|
||||
using LoadResult = typename swift::CoarseGrainedDependencyGraphImpl::LoadResult;
|
||||
using LoadResult =
|
||||
typename swift::CoarseGrainedDependencyGraphImpl::LoadResult;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
@@ -268,10 +269,11 @@ public:
|
||||
}
|
||||
|
||||
/// Unlike the standard \c CoarseGrainedDependencyGraph, returns \c
|
||||
/// CoarseGrainedDependencyGraphImpl::LoadResult::AffectsDownstream when loading a new
|
||||
/// file, i.e. when determining the initial set. Caller compensates.
|
||||
CoarseGrainedDependencyGraphImpl::LoadResult loadFromPath(const driver::Job *, StringRef,
|
||||
DiagnosticEngine &);
|
||||
/// CoarseGrainedDependencyGraphImpl::LoadResult::AffectsDownstream when
|
||||
/// loading a new file, i.e. when determining the initial set. Caller
|
||||
/// compensates.
|
||||
CoarseGrainedDependencyGraphImpl::LoadResult
|
||||
loadFromPath(const driver::Job *, StringRef, DiagnosticEngine &);
|
||||
|
||||
/// For the dot file.
|
||||
std::string getGraphID() const { return "driver"; }
|
||||
@@ -372,12 +374,13 @@ private:
|
||||
/// and integrate it into the ModuleDepGraph.
|
||||
/// Used both the first time, and to reload the SourceFileDepGraph.
|
||||
/// If any changes were observed, indicate same in the return vale.
|
||||
CoarseGrainedDependencyGraphImpl::LoadResult loadFromBuffer(const driver::Job *,
|
||||
llvm::MemoryBuffer &);
|
||||
CoarseGrainedDependencyGraphImpl::LoadResult
|
||||
loadFromBuffer(const driver::Job *, llvm::MemoryBuffer &);
|
||||
|
||||
/// Integrate a SourceFileDepGraph into the receiver.
|
||||
/// Integration happens when the driver needs to read SourceFileDepGraph.
|
||||
CoarseGrainedDependencyGraphImpl::LoadResult integrate(const SourceFileDepGraph &);
|
||||
CoarseGrainedDependencyGraphImpl::LoadResult
|
||||
integrate(const SourceFileDepGraph &);
|
||||
|
||||
enum class LocationOfPreexistingNode { nowhere, here, elsewhere };
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "swift/Driver/CoarseGrainedDependencyGraph.h"
|
||||
#include "swift/Basic/ReferenceDependencyKeys.h"
|
||||
#include "swift/Basic/Statistic.h"
|
||||
#include "swift/Driver/CoarseGrainedDependencyGraph.h"
|
||||
#include "swift/Demangling/Demangle.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
@@ -43,7 +43,8 @@ public:
|
||||
DependencyMaskTy KindMask;
|
||||
};
|
||||
|
||||
CoarseGrainedDependencyGraphImpl::MarkTracerImpl::MarkTracerImpl(UnifiedStatsReporter *Stats)
|
||||
CoarseGrainedDependencyGraphImpl::MarkTracerImpl::MarkTracerImpl(
|
||||
UnifiedStatsReporter *Stats)
|
||||
: Stats(Stats) {}
|
||||
CoarseGrainedDependencyGraphImpl::MarkTracerImpl::~MarkTracerImpl() = default;
|
||||
|
||||
@@ -211,20 +212,22 @@ parseDependencyFile(llvm::MemoryBuffer &buffer,
|
||||
return result;
|
||||
}
|
||||
|
||||
LoadResult CoarseGrainedDependencyGraphImpl::loadFromPath(const void *node, StringRef path) {
|
||||
LoadResult CoarseGrainedDependencyGraphImpl::loadFromPath(const void *node,
|
||||
StringRef path) {
|
||||
auto buffer = llvm::MemoryBuffer::getFile(path);
|
||||
if (!buffer)
|
||||
return LoadResult::HadError;
|
||||
return loadFromBuffer(node, *buffer.get());
|
||||
}
|
||||
|
||||
LoadResult
|
||||
CoarseGrainedDependencyGraphImpl::loadFromString(const void *node, StringRef data) {
|
||||
LoadResult CoarseGrainedDependencyGraphImpl::loadFromString(const void *node,
|
||||
StringRef data) {
|
||||
auto buffer = llvm::MemoryBuffer::getMemBuffer(data);
|
||||
return loadFromBuffer(node, *buffer);
|
||||
}
|
||||
|
||||
LoadResult CoarseGrainedDependencyGraphImpl::loadFromBuffer(const void *node,
|
||||
LoadResult
|
||||
CoarseGrainedDependencyGraphImpl::loadFromBuffer(const void *node,
|
||||
llvm::MemoryBuffer &buffer) {
|
||||
auto &provides = Provides[node];
|
||||
|
||||
@@ -294,8 +297,8 @@ LoadResult CoarseGrainedDependencyGraphImpl::loadFromBuffer(const void *node,
|
||||
interfaceHashCallback);
|
||||
}
|
||||
|
||||
void CoarseGrainedDependencyGraphImpl::markExternal(SmallVectorImpl<const void *> &visited,
|
||||
StringRef externalDependency) {
|
||||
void CoarseGrainedDependencyGraphImpl::markExternal(
|
||||
SmallVectorImpl<const void *> &visited, StringRef externalDependency) {
|
||||
forEachUnmarkedJobDirectlyDependentOnExternalSwiftdeps(
|
||||
externalDependency, [&](const void *node) {
|
||||
visited.push_back(node);
|
||||
@@ -319,9 +322,9 @@ void CoarseGrainedDependencyGraphImpl::
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoarseGrainedDependencyGraphImpl::markTransitive(SmallVectorImpl<const void *> &visited,
|
||||
const void *node, MarkTracerImpl *tracer) {
|
||||
void CoarseGrainedDependencyGraphImpl::markTransitive(
|
||||
SmallVectorImpl<const void *> &visited, const void *node,
|
||||
MarkTracerImpl *tracer) {
|
||||
assert(Provides.count(node) && "node is not in the graph");
|
||||
llvm::SpecificBumpPtrAllocator<MarkTracerImpl::Entry> scratchAlloc;
|
||||
|
||||
|
||||
@@ -239,7 +239,8 @@ namespace driver {
|
||||
///
|
||||
/// Dependency graphs for deciding which jobs are dirty (need running)
|
||||
/// or clean (can be skipped).
|
||||
using CoarseGrainedDependencyGraph = CoarseGrainedDependencyGraph<const Job *>;
|
||||
using CoarseGrainedDependencyGraph =
|
||||
CoarseGrainedDependencyGraph<const Job *>;
|
||||
CoarseGrainedDependencyGraph CoarseGrainedDepGraph;
|
||||
CoarseGrainedDependencyGraph CoarseGrainedDepGraphForRanges;
|
||||
|
||||
@@ -1586,19 +1587,18 @@ namespace driver {
|
||||
: getDepGraph(forRanges).markIntransitive(Cmd);
|
||||
}
|
||||
|
||||
CoarseGrainedDependencyGraph::LoadResult loadDepGraphFromPath(const Job *Cmd,
|
||||
StringRef path,
|
||||
DiagnosticEngine &diags,
|
||||
const bool forRanges) {
|
||||
CoarseGrainedDependencyGraph::LoadResult
|
||||
loadDepGraphFromPath(const Job *Cmd, StringRef path,
|
||||
DiagnosticEngine &diags, const bool forRanges) {
|
||||
return Comp.getEnableFineGrainedDependencies()
|
||||
? getExpDepGraph(forRanges).loadFromPath(Cmd, path, diags)
|
||||
: getDepGraph(forRanges).loadFromPath(Cmd, path, diags);
|
||||
}
|
||||
|
||||
template <unsigned N>
|
||||
void
|
||||
markTransitiveInDepGraph(SmallVector<const Job *, N> &visited,
|
||||
const Job *Cmd, const bool forRanges,
|
||||
void markTransitiveInDepGraph(
|
||||
SmallVector<const Job *, N> &visited, const Job *Cmd,
|
||||
const bool forRanges,
|
||||
CoarseGrainedDependencyGraph::MarkTracer *tracer = nullptr) {
|
||||
if (Comp.getEnableFineGrainedDependencies())
|
||||
getExpDepGraph(forRanges).markTransitive(visited, Cmd, tracer);
|
||||
@@ -1624,7 +1624,8 @@ namespace driver {
|
||||
getExpDepGraph(const bool forRanges) const {
|
||||
return forRanges ? ExpDepGraphForRanges : ExpDepGraph;
|
||||
}
|
||||
const CoarseGrainedDependencyGraph &getDepGraph(const bool forRanges) const {
|
||||
const CoarseGrainedDependencyGraph &
|
||||
getDepGraph(const bool forRanges) const {
|
||||
return forRanges ? CoarseGrainedDepGraphForRanges : CoarseGrainedDepGraph;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -41,7 +41,8 @@ using namespace swift::driver;
|
||||
// MARK: Interfacing to Compilation
|
||||
//==============================================================================
|
||||
|
||||
using LoadResult = fine_grained_dependencies::CoarseGrainedDependencyGraphImpl::LoadResult;
|
||||
using LoadResult =
|
||||
fine_grained_dependencies::CoarseGrainedDependencyGraphImpl::LoadResult;
|
||||
|
||||
LoadResult ModuleDepGraph::loadFromPath(const Job *Cmd, StringRef path,
|
||||
DiagnosticEngine &diags) {
|
||||
|
||||
@@ -6,26 +6,27 @@ using namespace swift;
|
||||
using LoadResult = CoarseGrainedDependencyGraphImpl::LoadResult;
|
||||
using namespace reference_dependency_keys;
|
||||
|
||||
static LoadResult loadFromString(CoarseGrainedDependencyGraph<uintptr_t> &dg, uintptr_t node,
|
||||
StringRef key, StringRef data) {
|
||||
static LoadResult loadFromString(CoarseGrainedDependencyGraph<uintptr_t> &dg,
|
||||
uintptr_t node, StringRef key,
|
||||
StringRef data) {
|
||||
return dg.loadFromString(node, key.str() + ": [" + data.str() + "]");
|
||||
}
|
||||
|
||||
static LoadResult loadFromString(CoarseGrainedDependencyGraph<uintptr_t> &dg, uintptr_t node,
|
||||
StringRef key1, StringRef data1,
|
||||
StringRef key2, StringRef data2) {
|
||||
return dg.loadFromString(node,
|
||||
key1.str() + ": [" + data1.str() + "]\n" +
|
||||
static LoadResult loadFromString(CoarseGrainedDependencyGraph<uintptr_t> &dg,
|
||||
uintptr_t node, StringRef key1,
|
||||
StringRef data1, StringRef key2,
|
||||
StringRef data2) {
|
||||
return dg.loadFromString(node, key1.str() + ": [" + data1.str() + "]\n" +
|
||||
key2.str() + ": [" + data2.str() + "]");
|
||||
}
|
||||
|
||||
static LoadResult loadFromString(CoarseGrainedDependencyGraph<uintptr_t> &dg, uintptr_t node,
|
||||
StringRef key1, StringRef data1,
|
||||
StringRef key2, StringRef data2,
|
||||
StringRef key3, StringRef data3,
|
||||
StringRef key4, StringRef data4) {
|
||||
return dg.loadFromString(node,
|
||||
key1.str() + ": [" + data1.str() + "]\n" +
|
||||
static LoadResult loadFromString(CoarseGrainedDependencyGraph<uintptr_t> &dg,
|
||||
uintptr_t node, StringRef key1,
|
||||
StringRef data1, StringRef key2,
|
||||
StringRef data2, StringRef key3,
|
||||
StringRef data3, StringRef key4,
|
||||
StringRef data4) {
|
||||
return dg.loadFromString(node, key1.str() + ": [" + data1.str() + "]\n" +
|
||||
key2.str() + ": [" + data2.str() + "]\n" +
|
||||
key3.str() + ": [" + data3.str() + "]\n" +
|
||||
key4.str() + ": [" + data4.str() + "]\n");
|
||||
|
||||
Reference in New Issue
Block a user