Skip to content

Commit 8aff9d6

Browse files
committed
Better output formatting for the debug info
1 parent 75ff7b1 commit 8aff9d6

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

taichi/ir/ir.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ IRNode *Stmt::get_parent() const {
204204
}
205205

206206
std::string Stmt::get_last_tb() const {
207+
const auto *callable = get_callable();
208+
const auto callable_name = callable ? callable->get_name() : "";
209+
210+
std::string prefix =
211+
!callable_name.empty() ? "While compiling `" + callable_name + "`, " : "";
212+
207213
const auto &tb = dbg_info.tb;
208214
if (tb.empty()) {
209215
// If has no tb, try to find tb from the immediate previous statement
@@ -215,21 +221,19 @@ std::string Stmt::get_last_tb() const {
215221
while (it_this != parent->statements.rend()) {
216222
const auto &stmt = *it_this;
217223
if (!stmt->get_tb().empty()) {
218-
return stmt->get_tb();
224+
return prefix + stmt->get_tb();
219225
}
220226
++it_this;
221227
}
222228
}
223229

224230
const auto stmt_type_name = typeid(*this).name();
225-
const auto *callable = get_callable();
226-
const auto callable_name = callable ? callable->get_name() : "";
227231

228-
return fmt::format("{}::{} of type {}\n", callable_name, name(),
232+
return fmt::format("{}Statement {} (type={});\n", prefix, name(),
229233
cpp_demangle(stmt_type_name));
230234
}
231235

232-
return tb;
236+
return prefix + tb;
233237
}
234238

235239
std::vector<Stmt *> Stmt::get_operands() const {

0 commit comments

Comments
 (0)