Skip to content

Commit 1d72ec9

Browse files
authored
[AutoDiff] NFC: improve debug logging. (#33793)
Print value/instruction with context in non-differentiability error debug log.
1 parent a54765b commit 1d72ec9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

include/swift/SILOptimizer/Differentiation/ADContext.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ ADContext::emitNondifferentiabilityError(SILValue value,
273273
Diag<T...> diag, U &&... args) {
274274
LLVM_DEBUG({
275275
getADDebugStream() << "Diagnosing non-differentiability.\n";
276-
getADDebugStream() << "For value:\n" << value;
276+
auto &s = getADDebugStream() << "For value:\n";
277+
value->printInContext(s);
277278
getADDebugStream() << "With invoker:\n" << invoker << '\n';
278279
});
279280
// If instruction does not have a valid location, use the function location
@@ -290,7 +291,8 @@ ADContext::emitNondifferentiabilityError(SILInstruction *inst,
290291
Diag<T...> diag, U &&... args) {
291292
LLVM_DEBUG({
292293
getADDebugStream() << "Diagnosing non-differentiability.\n";
293-
getADDebugStream() << "For instruction:\n" << *inst;
294+
auto &s = getADDebugStream() << "For instruction:\n";
295+
inst->printInContext(s);
294296
getADDebugStream() << "With invoker:\n" << invoker << '\n';
295297
});
296298
// If instruction does not have a valid location, use the function location

0 commit comments

Comments
 (0)