Skip to content

Commit 6b48eb6

Browse files
committed
RequirementMachine: More debug output from RewritePath::RewriteSystem::propagateRedundantRequirementIDs()
1 parent 7d51fa9 commit 6b48eb6

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

lib/AST/RequirementMachine/HomotopyReduction.cpp

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -126,39 +126,51 @@ void RewriteSystem::propagateRedundantRequirementIDs() {
126126
llvm::dbgs() << "\nPropagating requirement IDs: {";
127127
}
128128

129-
for (auto ruleAndReplacement : RedundantRules) {
130-
auto ruleID = ruleAndReplacement.first;
131-
auto rewritePath = ruleAndReplacement.second;
132-
auto &rule = Rules[ruleID];
129+
for (const auto &ruleAndReplacement : RedundantRules) {
130+
unsigned ruleID = ruleAndReplacement.first;
131+
const auto &rewritePath = ruleAndReplacement.second;
132+
const auto &rule = Rules[ruleID];
133133

134134
auto requirementID = rule.getRequirementID();
135-
if (!requirementID.hasValue())
135+
if (!requirementID.hasValue()) {
136+
if (Debug.contains(DebugFlags::PropagateRequirementIDs)) {
137+
llvm::dbgs() << "\n- rule does not have a requirement ID: "
138+
<< rule;
139+
}
136140
continue;
141+
}
137142

138143
MutableTerm lhs(rule.getLHS());
139144
for (auto ruleID : rewritePath.findRulesAppearingOnceInEmptyContext(lhs, *this)) {
140145
auto &replacement = Rules[ruleID];
141-
if (!replacement.isPermanent()) {
142-
// If the replacement rule already has a requirementID, overwrite
143-
// it if the existing ID corresponds to an inferred requirement.
144-
// This effectively makes the inferred requirement the redundant
145-
// one, which makes it easier to suppress redundancy warnings for
146-
// inferred requirements later on.
147-
auto existingID = replacement.getRequirementID();
148-
if (existingID.hasValue() && !WrittenRequirements[*existingID].inferred)
149-
continue;
146+
if (replacement.isPermanent()) {
147+
if (Debug.contains(DebugFlags::PropagateRequirementIDs)) {
148+
llvm::dbgs() << "\n- skipping permanent rule: " << rule;
149+
}
150+
continue;
151+
}
150152

153+
// If the replacement rule already has a requirementID, overwrite
154+
// it if the existing ID corresponds to an inferred requirement.
155+
// This effectively makes the inferred requirement the redundant
156+
// one, which makes it easier to suppress redundancy warnings for
157+
// inferred requirements later on.
158+
auto existingID = replacement.getRequirementID();
159+
if (existingID.hasValue() && !WrittenRequirements[*existingID].inferred) {
151160
if (Debug.contains(DebugFlags::PropagateRequirementIDs)) {
152-
llvm::dbgs() << "\n- propagating ID = "
153-
<< requirementID
154-
<< "\n from ";
155-
rule.dump(llvm::dbgs());
156-
llvm::dbgs() << "\n to ";
157-
replacement.dump(llvm::dbgs());
161+
llvm::dbgs() << "\n- rule already has a requirement ID: "
162+
<< rule;
158163
}
164+
continue;
165+
}
159166

160-
replacement.setRequirementID(requirementID);
167+
if (Debug.contains(DebugFlags::PropagateRequirementIDs)) {
168+
llvm::dbgs() << "\n- propagating ID = " << requirementID
169+
<< "\n from " << rule;
170+
llvm::dbgs() << "\n to " << replacement;
161171
}
172+
173+
replacement.setRequirementID(requirementID);
162174
}
163175
}
164176

0 commit comments

Comments
 (0)