Skip to content

Commit ce81fec

Browse files
committed
[sil] Dump the unknown users when the address walker fails to visit an instructions.
Just making this easier to debug. Previously, one would have to go into the debugger to figure out what the issue is. Now upon failure, one just gets the exact instruction that needs to be added.
1 parent f5e5789 commit ce81fec

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,18 +729,30 @@ struct ImmutableAddressUseVerifier {
729729
};
730730

731731
static void checkAddressWalkerCanVisitAllTransitiveUses(SILValue address) {
732+
SmallVector<SILInstruction *, 8> badUsers;
732733
struct Visitor : TransitiveAddressWalker<Visitor> {
734+
SmallVectorImpl<SILInstruction *> &badUsers;
735+
Visitor(SmallVectorImpl<SILInstruction *> &badUsers)
736+
: TransitiveAddressWalker<Visitor>(), badUsers(badUsers) {}
733737
bool visitUse(Operand *use) { return true; }
734-
void onError(Operand *use) {}
738+
void onError(Operand *use) {
739+
badUsers.push_back(use->getUser());
740+
}
735741
};
736742

737-
Visitor visitor;
743+
Visitor visitor(badUsers);
738744
if (std::move(visitor).walk(address) != AddressUseKind::Unknown)
739745
return;
740746

741747
llvm::errs() << "TransitiveAddressWalker walker failed to know how to visit "
742748
"a user when visiting: "
743-
<< *address << '\n';
749+
<< *address;
750+
if (badUsers.size()) {
751+
llvm::errs() << "Bad Users:\n";
752+
for (auto *user : badUsers) {
753+
llvm::errs() << " " << *user;
754+
}
755+
}
744756
llvm::report_fatal_error("invoking standard assertion failure");
745757
}
746758

0 commit comments

Comments
 (0)