Skip to content

[Basic] Renamed GraphNodeWorklist. #39802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===--- DAGNodeWorklist.h --------------------------------------*- C++ -*-===//
//===--- GraphNodeWorklist.h ------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
Expand All @@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_BASIC_DAGNODEWORKLIST_H
#define SWIFT_BASIC_DAGNODEWORKLIST_H
#ifndef SWIFT_BASIC_GRAPHNODEWORKLIST_H
#define SWIFT_BASIC_GRAPHNODEWORKLIST_H

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

DAGNodeWorklist() = default;
GraphNodeWorklist() = default;

DAGNodeWorklist(const DAGNodeWorklist &) = delete;
GraphNodeWorklist(const GraphNodeWorklist &) = delete;

void initialize(T t) {
clear();
insert(t);
}

template <typename R> void initializeRange(R &&range) {
template <typename R>
void initializeRange(R &&range) {
clear();
nodeVisited.insert(range.begin(), range.end());
nodeVector.append(range.begin(), range.end());
Expand All @@ -64,4 +63,4 @@ template <typename T, unsigned SmallSize> struct DAGNodeWorklist {
}
};

#endif // SWIFT_BASIC_DAGNODEWORKLIST_H
#endif // SWIFT_BASIC_GRAPHNODEWORKLIST_H
6 changes: 3 additions & 3 deletions include/swift/SILOptimizer/Utils/CanonicalOSSALifetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
#ifndef SWIFT_SILOPTIMIZER_UTILS_CANONICALOSSALIFETIME_H
#define SWIFT_SILOPTIMIZER_UTILS_CANONICALOSSALIFETIME_H

#include "swift/Basic/DAGNodeWorklist.h"
#include "swift/Basic/GraphNodeWorklist.h"
#include "swift/Basic/SmallPtrSetVector.h"
#include "swift/SIL/PrunedLiveness.h"
#include "swift/SIL/SILInstruction.h"
Expand Down Expand Up @@ -271,10 +271,10 @@ class CanonicalizeOSSALifetime {
llvm::SmallPtrSet<DebugValueInst *, 8> debugValues;

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

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

/// Pruned liveness for the extended live range including copies. For this
/// purpose, only consuming instructions are considered "lifetime
Expand Down
6 changes: 3 additions & 3 deletions include/swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#ifndef SWIFT_SILOPTIMIZER_UTILS_CANONICALIZEBORROWSCOPES_H
#define SWIFT_SILOPTIMIZER_UTILS_CANONICALIZEBORROWSCOPES_H

#include "swift/Basic/DAGNodeWorklist.h"
#include "swift/Basic/GraphNodeWorklist.h"
#include "swift/Basic/SmallPtrSetVector.h"
#include "swift/SIL/OwnershipUtils.h"
#include "swift/SIL/PrunedLiveness.h"
Expand Down Expand Up @@ -69,10 +69,10 @@ class CanonicalizeBorrowScope {
InstructionDeleter &deleter;

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

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

/// Record any copies outside the borrow scope that were updated. This
/// includes the outer copy that us used by outer uses and copies for any
Expand Down
7 changes: 3 additions & 4 deletions lib/SIL/Utils/OwnershipUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
//===----------------------------------------------------------------------===//

#include "swift/SIL/OwnershipUtils.h"
#include "swift/Basic/DAGNodeWorklist.h"
#include "swift/Basic/Defer.h"
#include "swift/Basic/DAGNodeWorklist.h"
#include "swift/Basic/GraphNodeWorklist.h"
#include "swift/Basic/SmallPtrSetVector.h"
#include "swift/SIL/InstructionUtils.h"
#include "swift/SIL/LinearLifetimeChecker.h"
Expand Down Expand Up @@ -179,7 +178,7 @@ bool swift::findInnerTransitiveGuaranteedUses(
// grow exponentially without the membership check. It's fine to do this
// membership check locally in this function (within a borrow scope) because
// it isn't needed for the immediate uses, only the transitive uses.
DAGNodeWorklist<Operand *, 8> worklist;
GraphNodeWorklist<Operand *, 8> worklist;
for (Operand *use : guaranteedValue->getUses()) {
if (use->getOperandOwnership() != OperandOwnership::NonUse)
worklist.insert(use);
Expand Down Expand Up @@ -1438,7 +1437,7 @@ void swift::findTransitiveReborrowBaseValuePairs(
void swift::visitTransitiveEndBorrows(
BorrowedValue beginBorrow,
function_ref<void(EndBorrowInst *)> visitEndBorrow) {
DAGNodeWorklist<SILValue, 4> worklist;
GraphNodeWorklist<SILValue, 4> worklist;
worklist.insert(beginBorrow.value);

while (!worklist.empty()) {
Expand Down
4 changes: 2 additions & 2 deletions lib/SILOptimizer/Transforms/SILMem2Reg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define DEBUG_TYPE "sil-mem2reg"

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

DAGNodeWorklist<ScopeEndPosition, 16> worklist;
GraphNodeWorklist<ScopeEndPosition, 16> worklist;
for (auto pair : initializationPoints) {
worklist.insert({pair.getFirst(), AvailableValuesKind::Out});
}
Expand Down