Skip to content

Commit 5dab47c

Browse files
committed
SILPrinter: split printUsersOfSILNode into printUsersOfValue and printUsersOfInstruction.
A small cleanup, NFC.
1 parent f812a2a commit 5dab47c

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

lib/SIL/IR/SILPrinter.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -761,17 +761,18 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
761761

762762
/// Print out the users of the SILValue \p V. Return true if we printed out
763763
/// either an id or a use list. Return false otherwise.
764-
bool printUsersOfSILNode(const SILNode *node, bool printedSlashes) {
764+
bool printUsersOfValue(SILValue value, bool printedSlashes) {
765+
return printUserList({value}, value, printedSlashes);
766+
}
767+
768+
bool printUsersOfInstruction(const SILInstruction *inst, bool printedSlashes) {
765769
llvm::SmallVector<SILValue, 8> values;
766-
if (auto *value = dyn_cast<ValueBase>(node)) {
767-
values.push_back(value);
768-
} else if (auto *inst = dyn_cast<SILInstruction>(node)) {
769-
assert(!isa<SingleValueInstruction>(inst) && "SingleValueInstruction was "
770-
"handled by the previous "
771-
"value base check.");
772-
llvm::copy(inst->getResults(), std::back_inserter(values));
773-
}
770+
llvm::copy(inst->getResults(), std::back_inserter(values));
771+
return printUserList(values, inst, printedSlashes);
772+
}
774773

774+
bool printUserList(ArrayRef<SILValue> values, const SILNode *node,
775+
bool printedSlashes) {
775776
// If the set of values is empty, we need to print the ID of
776777
// the instruction. Otherwise, if none of the values has a use,
777778
// we don't need to do anything.
@@ -1011,7 +1012,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
10111012
printedSlashes = printTypeDependentOperands(I);
10121013

10131014
// Print users, or id for valueless instructions.
1014-
printedSlashes = printUsersOfSILNode(I, printedSlashes);
1015+
printedSlashes = printUsersOfInstruction(I, printedSlashes);
10151016

10161017
// Print SIL location.
10171018
if (Ctx.printVerbose()) {
@@ -1056,7 +1057,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
10561057
<< Ctx.getID(arg->getParent()) << " : " << arg->getType();
10571058

10581059
// Print users.
1059-
(void) printUsersOfSILNode(arg, false);
1060+
(void) printUsersOfValue(arg, false);
10601061

10611062
*this << '\n';
10621063
}
@@ -1093,7 +1094,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
10931094
visit(static_cast<SILInstruction *>(nonConstParent));
10941095

10951096
// Print users.
1096-
(void)printUsersOfSILNode(result, false);
1097+
(void)printUsersOfValue(result, false);
10971098

10981099
*this << '\n';
10991100
}

0 commit comments

Comments
 (0)