Skip to content

Commit bc068ae

Browse files
author
David Ungar
committed
format
1 parent 8dc04c7 commit bc068ae

File tree

6 files changed

+82
-69
lines changed

6 files changed

+82
-69
lines changed

include/swift/Driver/CoarseGrainedDependencyGraph.h

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ class CoarseGrainedDependencyGraphImpl {
4343
public:
4444
/// Possible dependency kinds.
4545
///
46-
/// Clients of CoarseGrainedDependencyGraph should have no reason to use this type.
47-
/// It is only used in the implementation.
46+
/// Clients of CoarseGrainedDependencyGraph should have no reason to use this
47+
/// type. It is only used in the implementation.
4848
enum class DependencyKind : uint8_t;
4949

5050
/// Describes the result of loading a dependency file for a particular node.
@@ -62,7 +62,8 @@ class CoarseGrainedDependencyGraphImpl {
6262
AffectsDownstream
6363
};
6464

65-
/// The non-templated implementation of CoarseGrainedDependencyGraph::MarkTracer.
65+
/// The non-templated implementation of
66+
/// CoarseGrainedDependencyGraph::MarkTracer.
6667
///
6768
/// \see CoarseGrainedDependencyGraph::MarkTracer
6869
class MarkTracerImpl {
@@ -71,6 +72,7 @@ class CoarseGrainedDependencyGraphImpl {
7172
UnifiedStatsReporter *Stats;
7273

7374
friend class CoarseGrainedDependencyGraphImpl;
75+
7476
protected:
7577
explicit MarkTracerImpl(UnifiedStatsReporter *Stats);
7678
~MarkTracerImpl();
@@ -210,7 +212,8 @@ class CoarseGrainedDependencyGraph : public CoarseGrainedDependencyGraphImpl {
210212
}
211213

212214
public:
213-
/// Traces the graph traversal performed in CoarseGrainedDependencyGraph::markTransitive.
215+
/// Traces the graph traversal performed in
216+
/// CoarseGrainedDependencyGraph::markTransitive.
214217
///
215218
/// This is intended to be a debugging aid.
216219
class MarkTracer : public MarkTracerImpl {
@@ -240,8 +243,8 @@ class CoarseGrainedDependencyGraph : public CoarseGrainedDependencyGraphImpl {
240243
/// call site can polymorphically call \ref
241244
/// fine_grained_dependencies::ModuleDepGraph::loadFromPath
242245
LoadResult loadFromPath(T node, StringRef path, DiagnosticEngine &) {
243-
return CoarseGrainedDependencyGraphImpl::loadFromPath(Traits::getAsVoidPointer(node),
244-
path);
246+
return CoarseGrainedDependencyGraphImpl::loadFromPath(
247+
Traits::getAsVoidPointer(node), path);
245248
}
246249

247250
/// Load "depends" and "provides" data for \p node from a plain string.
@@ -250,16 +253,16 @@ class CoarseGrainedDependencyGraph : public CoarseGrainedDependencyGraphImpl {
250253
///
251254
/// \sa loadFromPath
252255
LoadResult loadFromString(T node, StringRef data) {
253-
return CoarseGrainedDependencyGraphImpl::loadFromString(Traits::getAsVoidPointer(node),
254-
data);
256+
return CoarseGrainedDependencyGraphImpl::loadFromString(
257+
Traits::getAsVoidPointer(node), data);
255258
}
256259

257260
/// Adds \p node to the dependency graph without any connections.
258261
///
259262
/// This can be used for new nodes that may be updated later.
260263
void addIndependentNode(T node) {
261-
return
262-
CoarseGrainedDependencyGraphImpl::addIndependentNode(Traits::getAsVoidPointer(node));
264+
return CoarseGrainedDependencyGraphImpl::addIndependentNode(
265+
Traits::getAsVoidPointer(node));
263266
}
264267

265268
/// Marks \p node and all nodes that depend on \p node, and places any nodes
@@ -287,17 +290,17 @@ class CoarseGrainedDependencyGraph : public CoarseGrainedDependencyGraphImpl {
287290
void markTransitive(SmallVector<T, N> &visited, T node,
288291
MarkTracer *tracer = nullptr) {
289292
SmallVector<const void *, N> rawMarked;
290-
CoarseGrainedDependencyGraphImpl::markTransitive(rawMarked,
291-
Traits::getAsVoidPointer(node),
292-
tracer);
293+
CoarseGrainedDependencyGraphImpl::markTransitive(
294+
rawMarked, Traits::getAsVoidPointer(node), tracer);
293295
// FIXME: How can we avoid this copy?
294296
copyBack(visited, rawMarked);
295297
}
296298

297299
template <unsigned N>
298300
void markExternal(SmallVector<T, N> &visited, StringRef externalDependency) {
299301
SmallVector<const void *, N> rawMarked;
300-
CoarseGrainedDependencyGraphImpl::markExternal(rawMarked, externalDependency);
302+
CoarseGrainedDependencyGraphImpl::markExternal(rawMarked,
303+
externalDependency);
301304
// FIXME: How can we avoid this copy?
302305
copyBack(visited, rawMarked);
303306
}
@@ -308,13 +311,14 @@ class CoarseGrainedDependencyGraph : public CoarseGrainedDependencyGraphImpl {
308311
///
309312
/// \sa #markTransitive
310313
bool markIntransitive(T node) {
311-
return
312-
CoarseGrainedDependencyGraphImpl::markIntransitive(Traits::getAsVoidPointer(node));
314+
return CoarseGrainedDependencyGraphImpl::markIntransitive(
315+
Traits::getAsVoidPointer(node));
313316
}
314317

315318
/// Returns true if \p node has been marked (directly or transitively).
316319
bool isMarked(T node) const {
317-
return CoarseGrainedDependencyGraphImpl::isMarked(Traits::getAsVoidPointer(node));
320+
return CoarseGrainedDependencyGraphImpl::isMarked(
321+
Traits::getAsVoidPointer(node));
318322
}
319323
};
320324

include/swift/Driver/FineGrainedDependencyDriverGraph.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ class ModuleDepGraphNode : public DepGraphNode {
110110
class CoarseGrainedDependencyGraphImpl {
111111
public:
112112
/// Use the status quo LoadResult for now.
113-
using LoadResult = typename swift::CoarseGrainedDependencyGraphImpl::LoadResult;
113+
using LoadResult =
114+
typename swift::CoarseGrainedDependencyGraphImpl::LoadResult;
114115
};
115116

116117
//==============================================================================
@@ -268,10 +269,11 @@ class ModuleDepGraph {
268269
}
269270

270271
/// Unlike the standard \c CoarseGrainedDependencyGraph, returns \c
271-
/// CoarseGrainedDependencyGraphImpl::LoadResult::AffectsDownstream when loading a new
272-
/// file, i.e. when determining the initial set. Caller compensates.
273-
CoarseGrainedDependencyGraphImpl::LoadResult loadFromPath(const driver::Job *, StringRef,
274-
DiagnosticEngine &);
272+
/// CoarseGrainedDependencyGraphImpl::LoadResult::AffectsDownstream when
273+
/// loading a new file, i.e. when determining the initial set. Caller
274+
/// compensates.
275+
CoarseGrainedDependencyGraphImpl::LoadResult
276+
loadFromPath(const driver::Job *, StringRef, DiagnosticEngine &);
275277

276278
/// For the dot file.
277279
std::string getGraphID() const { return "driver"; }
@@ -372,12 +374,13 @@ class ModuleDepGraph {
372374
/// and integrate it into the ModuleDepGraph.
373375
/// Used both the first time, and to reload the SourceFileDepGraph.
374376
/// If any changes were observed, indicate same in the return vale.
375-
CoarseGrainedDependencyGraphImpl::LoadResult loadFromBuffer(const driver::Job *,
376-
llvm::MemoryBuffer &);
377+
CoarseGrainedDependencyGraphImpl::LoadResult
378+
loadFromBuffer(const driver::Job *, llvm::MemoryBuffer &);
377379

378380
/// Integrate a SourceFileDepGraph into the receiver.
379381
/// Integration happens when the driver needs to read SourceFileDepGraph.
380-
CoarseGrainedDependencyGraphImpl::LoadResult integrate(const SourceFileDepGraph &);
382+
CoarseGrainedDependencyGraphImpl::LoadResult
383+
integrate(const SourceFileDepGraph &);
381384

382385
enum class LocationOfPreexistingNode { nowhere, here, elsewhere };
383386

lib/Driver/CoarseGrainedDependencyGraph.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "swift/Driver/CoarseGrainedDependencyGraph.h"
1314
#include "swift/Basic/ReferenceDependencyKeys.h"
1415
#include "swift/Basic/Statistic.h"
15-
#include "swift/Driver/CoarseGrainedDependencyGraph.h"
1616
#include "swift/Demangling/Demangle.h"
1717
#include "llvm/ADT/SmallString.h"
1818
#include "llvm/ADT/SmallVector.h"
@@ -43,8 +43,9 @@ class CoarseGrainedDependencyGraphImpl::MarkTracerImpl::Entry {
4343
DependencyMaskTy KindMask;
4444
};
4545

46-
CoarseGrainedDependencyGraphImpl::MarkTracerImpl::MarkTracerImpl(UnifiedStatsReporter *Stats)
47-
: Stats(Stats) {}
46+
CoarseGrainedDependencyGraphImpl::MarkTracerImpl::MarkTracerImpl(
47+
UnifiedStatsReporter *Stats)
48+
: Stats(Stats) {}
4849
CoarseGrainedDependencyGraphImpl::MarkTracerImpl::~MarkTracerImpl() = default;
4950

5051
using LoadResult = CoarseGrainedDependencyGraphImpl::LoadResult;
@@ -211,21 +212,23 @@ parseDependencyFile(llvm::MemoryBuffer &buffer,
211212
return result;
212213
}
213214

214-
LoadResult CoarseGrainedDependencyGraphImpl::loadFromPath(const void *node, StringRef path) {
215+
LoadResult CoarseGrainedDependencyGraphImpl::loadFromPath(const void *node,
216+
StringRef path) {
215217
auto buffer = llvm::MemoryBuffer::getFile(path);
216218
if (!buffer)
217219
return LoadResult::HadError;
218220
return loadFromBuffer(node, *buffer.get());
219221
}
220222

221-
LoadResult
222-
CoarseGrainedDependencyGraphImpl::loadFromString(const void *node, StringRef data) {
223+
LoadResult CoarseGrainedDependencyGraphImpl::loadFromString(const void *node,
224+
StringRef data) {
223225
auto buffer = llvm::MemoryBuffer::getMemBuffer(data);
224226
return loadFromBuffer(node, *buffer);
225227
}
226228

227-
LoadResult CoarseGrainedDependencyGraphImpl::loadFromBuffer(const void *node,
228-
llvm::MemoryBuffer &buffer) {
229+
LoadResult
230+
CoarseGrainedDependencyGraphImpl::loadFromBuffer(const void *node,
231+
llvm::MemoryBuffer &buffer) {
229232
auto &provides = Provides[node];
230233

231234
auto dependsCallback = [this, node](StringRef name, DependencyKind kind,
@@ -294,8 +297,8 @@ LoadResult CoarseGrainedDependencyGraphImpl::loadFromBuffer(const void *node,
294297
interfaceHashCallback);
295298
}
296299

297-
void CoarseGrainedDependencyGraphImpl::markExternal(SmallVectorImpl<const void *> &visited,
298-
StringRef externalDependency) {
300+
void CoarseGrainedDependencyGraphImpl::markExternal(
301+
SmallVectorImpl<const void *> &visited, StringRef externalDependency) {
299302
forEachUnmarkedJobDirectlyDependentOnExternalSwiftdeps(
300303
externalDependency, [&](const void *node) {
301304
visited.push_back(node);
@@ -319,9 +322,9 @@ void CoarseGrainedDependencyGraphImpl::
319322
}
320323
}
321324

322-
void
323-
CoarseGrainedDependencyGraphImpl::markTransitive(SmallVectorImpl<const void *> &visited,
324-
const void *node, MarkTracerImpl *tracer) {
325+
void CoarseGrainedDependencyGraphImpl::markTransitive(
326+
SmallVectorImpl<const void *> &visited, const void *node,
327+
MarkTracerImpl *tracer) {
325328
assert(Provides.count(node) && "node is not in the graph");
326329
llvm::SpecificBumpPtrAllocator<MarkTracerImpl::Entry> scratchAlloc;
327330

lib/Driver/Compilation.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ namespace driver {
239239
///
240240
/// Dependency graphs for deciding which jobs are dirty (need running)
241241
/// or clean (can be skipped).
242-
using CoarseGrainedDependencyGraph = CoarseGrainedDependencyGraph<const Job *>;
242+
using CoarseGrainedDependencyGraph =
243+
CoarseGrainedDependencyGraph<const Job *>;
243244
CoarseGrainedDependencyGraph CoarseGrainedDepGraph;
244245
CoarseGrainedDependencyGraph CoarseGrainedDepGraphForRanges;
245246

@@ -1586,20 +1587,19 @@ namespace driver {
15861587
: getDepGraph(forRanges).markIntransitive(Cmd);
15871588
}
15881589

1589-
CoarseGrainedDependencyGraph::LoadResult loadDepGraphFromPath(const Job *Cmd,
1590-
StringRef path,
1591-
DiagnosticEngine &diags,
1592-
const bool forRanges) {
1590+
CoarseGrainedDependencyGraph::LoadResult
1591+
loadDepGraphFromPath(const Job *Cmd, StringRef path,
1592+
DiagnosticEngine &diags, const bool forRanges) {
15931593
return Comp.getEnableFineGrainedDependencies()
15941594
? getExpDepGraph(forRanges).loadFromPath(Cmd, path, diags)
15951595
: getDepGraph(forRanges).loadFromPath(Cmd, path, diags);
15961596
}
15971597

15981598
template <unsigned N>
1599-
void
1600-
markTransitiveInDepGraph(SmallVector<const Job *, N> &visited,
1601-
const Job *Cmd, const bool forRanges,
1602-
CoarseGrainedDependencyGraph::MarkTracer *tracer = nullptr) {
1599+
void markTransitiveInDepGraph(
1600+
SmallVector<const Job *, N> &visited, const Job *Cmd,
1601+
const bool forRanges,
1602+
CoarseGrainedDependencyGraph::MarkTracer *tracer = nullptr) {
16031603
if (Comp.getEnableFineGrainedDependencies())
16041604
getExpDepGraph(forRanges).markTransitive(visited, Cmd, tracer);
16051605
else
@@ -1624,7 +1624,8 @@ namespace driver {
16241624
getExpDepGraph(const bool forRanges) const {
16251625
return forRanges ? ExpDepGraphForRanges : ExpDepGraph;
16261626
}
1627-
const CoarseGrainedDependencyGraph &getDepGraph(const bool forRanges) const {
1627+
const CoarseGrainedDependencyGraph &
1628+
getDepGraph(const bool forRanges) const {
16281629
return forRanges ? CoarseGrainedDepGraphForRanges : CoarseGrainedDepGraph;
16291630
}
16301631
};

lib/Driver/FineGrainedDependencyDriverGraph.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ using namespace swift::driver;
4141
// MARK: Interfacing to Compilation
4242
//==============================================================================
4343

44-
using LoadResult = fine_grained_dependencies::CoarseGrainedDependencyGraphImpl::LoadResult;
44+
using LoadResult =
45+
fine_grained_dependencies::CoarseGrainedDependencyGraphImpl::LoadResult;
4546

4647
LoadResult ModuleDepGraph::loadFromPath(const Job *Cmd, StringRef path,
4748
DiagnosticEngine &diags) {

unittests/Driver/CoarseGrainedDependencyGraphTests.cpp

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,30 @@ using namespace swift;
66
using LoadResult = CoarseGrainedDependencyGraphImpl::LoadResult;
77
using namespace reference_dependency_keys;
88

9-
static LoadResult loadFromString(CoarseGrainedDependencyGraph<uintptr_t> &dg, uintptr_t node,
10-
StringRef key, StringRef data) {
9+
static LoadResult loadFromString(CoarseGrainedDependencyGraph<uintptr_t> &dg,
10+
uintptr_t node, StringRef key,
11+
StringRef data) {
1112
return dg.loadFromString(node, key.str() + ": [" + data.str() + "]");
1213
}
1314

14-
static LoadResult loadFromString(CoarseGrainedDependencyGraph<uintptr_t> &dg, uintptr_t node,
15-
StringRef key1, StringRef data1,
16-
StringRef key2, StringRef data2) {
17-
return dg.loadFromString(node,
18-
key1.str() + ": [" + data1.str() + "]\n" +
19-
key2.str() + ": [" + data2.str() + "]");
20-
}
21-
22-
static LoadResult loadFromString(CoarseGrainedDependencyGraph<uintptr_t> &dg, uintptr_t node,
23-
StringRef key1, StringRef data1,
24-
StringRef key2, StringRef data2,
25-
StringRef key3, StringRef data3,
26-
StringRef key4, StringRef data4) {
27-
return dg.loadFromString(node,
28-
key1.str() + ": [" + data1.str() + "]\n" +
29-
key2.str() + ": [" + data2.str() + "]\n" +
30-
key3.str() + ": [" + data3.str() + "]\n" +
31-
key4.str() + ": [" + data4.str() + "]\n");
15+
static LoadResult loadFromString(CoarseGrainedDependencyGraph<uintptr_t> &dg,
16+
uintptr_t node, StringRef key1,
17+
StringRef data1, StringRef key2,
18+
StringRef data2) {
19+
return dg.loadFromString(node, key1.str() + ": [" + data1.str() + "]\n" +
20+
key2.str() + ": [" + data2.str() + "]");
21+
}
22+
23+
static LoadResult loadFromString(CoarseGrainedDependencyGraph<uintptr_t> &dg,
24+
uintptr_t node, StringRef key1,
25+
StringRef data1, StringRef key2,
26+
StringRef data2, StringRef key3,
27+
StringRef data3, StringRef key4,
28+
StringRef data4) {
29+
return dg.loadFromString(node, key1.str() + ": [" + data1.str() + "]\n" +
30+
key2.str() + ": [" + data2.str() + "]\n" +
31+
key3.str() + ": [" + data3.str() + "]\n" +
32+
key4.str() + ": [" + data4.str() + "]\n");
3233
}
3334

3435
TEST(CoarseGrainedDependencyGraph, BasicLoad) {

0 commit comments

Comments
 (0)