Skip to content

Commit c6d9084

Browse files
Merge pull request #39802 from nate-chandler/basic/graph-node-worklist-rename
[Basic] Renamed GraphNodeWorklist.
2 parents 275c341 + 42f318d commit c6d9084

File tree

5 files changed

+21
-23
lines changed

5 files changed

+21
-23
lines changed

include/swift/Basic/DAGNodeWorklist.h renamed to include/swift/Basic/GraphNodeWorklist.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- DAGNodeWorklist.h --------------------------------------*- C++ -*-===//
1+
//===--- GraphNodeWorklist.h ------------------------------------*- C++ -*-===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
@@ -10,8 +10,8 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#ifndef SWIFT_BASIC_DAGNODEWORKLIST_H
14-
#define SWIFT_BASIC_DAGNODEWORKLIST_H
13+
#ifndef SWIFT_BASIC_GRAPHNODEWORKLIST_H
14+
#define SWIFT_BASIC_GRAPHNODEWORKLIST_H
1515

1616
#include "swift/Basic/LLVM.h"
1717
#include "llvm/ADT/SmallPtrSet.h"
@@ -25,23 +25,22 @@
2525
///
2626
/// The primary API has two methods: intialize() and pop(). Others are provided
2727
/// for flexibility.
28-
///
29-
/// TODO: This also works well for cyclic graph traversal. Particularly CFG
30-
/// traversal. So we should probably just call it GraphNodeWorklist.
31-
template <typename T, unsigned SmallSize> struct DAGNodeWorklist {
28+
template <typename T, unsigned SmallSize>
29+
struct GraphNodeWorklist {
3230
llvm::SmallPtrSet<T, SmallSize> nodeVisited;
3331
llvm::SmallVector<T, SmallSize> nodeVector;
3432

35-
DAGNodeWorklist() = default;
33+
GraphNodeWorklist() = default;
3634

37-
DAGNodeWorklist(const DAGNodeWorklist &) = delete;
35+
GraphNodeWorklist(const GraphNodeWorklist &) = delete;
3836

3937
void initialize(T t) {
4038
clear();
4139
insert(t);
4240
}
4341

44-
template <typename R> void initializeRange(R &&range) {
42+
template <typename R>
43+
void initializeRange(R &&range) {
4544
clear();
4645
nodeVisited.insert(range.begin(), range.end());
4746
nodeVector.append(range.begin(), range.end());
@@ -64,4 +63,4 @@ template <typename T, unsigned SmallSize> struct DAGNodeWorklist {
6463
}
6564
};
6665

67-
#endif // SWIFT_BASIC_DAGNODEWORKLIST_H
66+
#endif // SWIFT_BASIC_GRAPHNODEWORKLIST_H

include/swift/SILOptimizer/Utils/CanonicalOSSALifetime.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
#ifndef SWIFT_SILOPTIMIZER_UTILS_CANONICALOSSALIFETIME_H
9797
#define SWIFT_SILOPTIMIZER_UTILS_CANONICALOSSALIFETIME_H
9898

99-
#include "swift/Basic/DAGNodeWorklist.h"
99+
#include "swift/Basic/GraphNodeWorklist.h"
100100
#include "swift/Basic/SmallPtrSetVector.h"
101101
#include "swift/SIL/PrunedLiveness.h"
102102
#include "swift/SIL/SILInstruction.h"
@@ -271,10 +271,10 @@ class CanonicalizeOSSALifetime {
271271
llvm::SmallPtrSet<DebugValueInst *, 8> debugValues;
272272

273273
/// Visited set for general def-use traversal that prevents revisiting values.
274-
DAGNodeWorklist<SILValue, 8> defUseWorklist;
274+
GraphNodeWorklist<SILValue, 8> defUseWorklist;
275275

276276
/// Visited set general CFG traversal that prevents revisiting blocks.
277-
DAGNodeWorklist<SILBasicBlock *, 8> blockWorklist;
277+
GraphNodeWorklist<SILBasicBlock *, 8> blockWorklist;
278278

279279
/// Pruned liveness for the extended live range including copies. For this
280280
/// purpose, only consuming instructions are considered "lifetime

include/swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#ifndef SWIFT_SILOPTIMIZER_UTILS_CANONICALIZEBORROWSCOPES_H
2828
#define SWIFT_SILOPTIMIZER_UTILS_CANONICALIZEBORROWSCOPES_H
2929

30-
#include "swift/Basic/DAGNodeWorklist.h"
30+
#include "swift/Basic/GraphNodeWorklist.h"
3131
#include "swift/Basic/SmallPtrSetVector.h"
3232
#include "swift/SIL/OwnershipUtils.h"
3333
#include "swift/SIL/PrunedLiveness.h"
@@ -69,10 +69,10 @@ class CanonicalizeBorrowScope {
6969
InstructionDeleter &deleter;
7070

7171
/// Visited set for general def-use traversal that prevents revisiting values.
72-
DAGNodeWorklist<SILValue, 8> defUseWorklist;
72+
GraphNodeWorklist<SILValue, 8> defUseWorklist;
7373

7474
/// Visited set general CFG traversal that prevents revisiting blocks.
75-
DAGNodeWorklist<SILBasicBlock *, 8> blockWorklist;
75+
GraphNodeWorklist<SILBasicBlock *, 8> blockWorklist;
7676

7777
/// Record any copies outside the borrow scope that were updated. This
7878
/// includes the outer copy that us used by outer uses and copies for any

lib/SIL/Utils/OwnershipUtils.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "swift/SIL/OwnershipUtils.h"
14-
#include "swift/Basic/DAGNodeWorklist.h"
1514
#include "swift/Basic/Defer.h"
16-
#include "swift/Basic/DAGNodeWorklist.h"
15+
#include "swift/Basic/GraphNodeWorklist.h"
1716
#include "swift/Basic/SmallPtrSetVector.h"
1817
#include "swift/SIL/InstructionUtils.h"
1918
#include "swift/SIL/LinearLifetimeChecker.h"
@@ -179,7 +178,7 @@ bool swift::findInnerTransitiveGuaranteedUses(
179178
// grow exponentially without the membership check. It's fine to do this
180179
// membership check locally in this function (within a borrow scope) because
181180
// it isn't needed for the immediate uses, only the transitive uses.
182-
DAGNodeWorklist<Operand *, 8> worklist;
181+
GraphNodeWorklist<Operand *, 8> worklist;
183182
for (Operand *use : guaranteedValue->getUses()) {
184183
if (use->getOperandOwnership() != OperandOwnership::NonUse)
185184
worklist.insert(use);
@@ -1438,7 +1437,7 @@ void swift::findTransitiveReborrowBaseValuePairs(
14381437
void swift::visitTransitiveEndBorrows(
14391438
BorrowedValue beginBorrow,
14401439
function_ref<void(EndBorrowInst *)> visitEndBorrow) {
1441-
DAGNodeWorklist<SILValue, 4> worklist;
1440+
GraphNodeWorklist<SILValue, 4> worklist;
14421441
worklist.insert(beginBorrow.value);
14431442

14441443
while (!worklist.empty()) {

lib/SILOptimizer/Transforms/SILMem2Reg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define DEBUG_TYPE "sil-mem2reg"
2222

2323
#include "swift/AST/DiagnosticsSIL.h"
24-
#include "swift/Basic/DAGNodeWorklist.h"
24+
#include "swift/Basic/GraphNodeWorklist.h"
2525
#include "swift/SIL/BasicBlockDatastructures.h"
2626
#include "swift/SIL/Dominance.h"
2727
#include "swift/SIL/Projection.h"
@@ -1132,7 +1132,7 @@ void StackAllocationPromoter::endLexicalLifetime(BlockSetVector &phiBlocks) {
11321132
using ScopeEndPosition =
11331133
llvm::PointerIntPair<SILBasicBlock *, 1, AvailableValuesKind>;
11341134

1135-
DAGNodeWorklist<ScopeEndPosition, 16> worklist;
1135+
GraphNodeWorklist<ScopeEndPosition, 16> worklist;
11361136
for (auto pair : initializationPoints) {
11371137
worklist.insert({pair.getFirst(), AvailableValuesKind::Out});
11381138
}

0 commit comments

Comments
 (0)