Skip to content

[AMDGPU] IGLP: Fix static variables #137549

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions llvm/include/llvm/CodeGen/ScheduleDAG.h
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,8 @@ class TargetRegisterInfo;
/// Makes a DFS traversal and mark all nodes affected by the edge insertion.
/// These nodes will later get new topological indexes by means of the Shift
/// method.
void DFS(const SUnit *SU, int UpperBound, bool& HasLoop);
void DFS(const SUnit *SU, int UpperBound, bool &HasLoop,
std::optional<SDep::Kind> OnlyDepKind = std::nullopt);

/// Reassigns topological indexes for the nodes in the DAG to
/// preserve the topological ordering.
Expand Down Expand Up @@ -767,7 +768,9 @@ class TargetRegisterInfo;
bool &Success);

/// Checks if \p SU is reachable from \p TargetSU.
bool IsReachable(const SUnit *SU, const SUnit *TargetSU);
/// If OnlyDepKind is given, consider only dependencies of this kind.
bool IsReachable(const SUnit *SU, const SUnit *TargetSU,
std::optional<SDep::Kind> OnlyDepKind = std::nullopt);

/// Returns true if addPred(TargetSU, SU) creates a cycle.
bool WillCreateCycle(SUnit *TargetSU, SUnit *SU);
Expand Down
6 changes: 4 additions & 2 deletions llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,10 @@ namespace llvm {
}

/// IsReachable - Checks if SU is reachable from TargetSU.
bool IsReachable(SUnit *SU, SUnit *TargetSU) {
return Topo.IsReachable(SU, TargetSU);
/// If OnlyDepKind is given, only dependencies of this kind are considered.
bool IsReachable(SUnit *SU, SUnit *TargetSU,
std::optional<SDep::Kind> OnlyDepKind = std::nullopt) {
return Topo.IsReachable(SU, TargetSU, OnlyDepKind);
}

/// Whether regions with a single MI should be scheduled.
Expand Down
12 changes: 8 additions & 4 deletions llvm/lib/CodeGen/ScheduleDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@ void ScheduleDAGTopologicalSort::RemovePred(SUnit *M, SUnit *N) {
}

void ScheduleDAGTopologicalSort::DFS(const SUnit *SU, int UpperBound,
bool &HasLoop) {
bool &HasLoop,
std::optional<SDep::Kind> OnlyDepKind) {
std::vector<const SUnit*> WorkList;
WorkList.reserve(SUnits.size());

Expand All @@ -580,6 +581,8 @@ void ScheduleDAGTopologicalSort::DFS(const SUnit *SU, int UpperBound,
WorkList.pop_back();
Visited.set(SU->NodeNum);
for (const SDep &SuccDep : llvm::reverse(SU->Succs)) {
if (OnlyDepKind && SuccDep.getKind() != *OnlyDepKind)
continue;
unsigned s = SuccDep.getSUnit()->NodeNum;
// Edges to non-SUnits are allowed but ignored (e.g. ExitSU).
if (s >= Node2Index.size())
Expand Down Expand Up @@ -722,8 +725,9 @@ void ScheduleDAGTopologicalSort::AddSUnitWithoutPredecessors(const SUnit *SU) {
Visited.resize(Node2Index.size());
}

bool ScheduleDAGTopologicalSort::IsReachable(const SUnit *SU,
const SUnit *TargetSU) {
bool ScheduleDAGTopologicalSort::IsReachable(
const SUnit *SU, const SUnit *TargetSU,
std::optional<SDep::Kind> OnlyDepKind) {
assert(TargetSU != nullptr && "Invalid target SUnit");
assert(SU != nullptr && "Invalid SUnit");
FixOrder();
Expand All @@ -737,7 +741,7 @@ bool ScheduleDAGTopologicalSort::IsReachable(const SUnit *SU,
if (LowerBound < UpperBound) {
Visited.reset();
// There may be a path from TargetSU to SU. Check for it.
DFS(TargetSU, UpperBound, HasLoop);
DFS(TargetSU, UpperBound, HasLoop, OnlyDepKind);
}
return HasLoop;
}
Expand Down
Loading