Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lang] Pass DebugInfo to frontend statements #8295

Merged
merged 27 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift click to select a range
151b392
Merge branch 'error-emitter-4-dbg_info-tb'
dream189free Jul 21, 2023
b24365e
Fix issues for passing src_info() to C
dream189free Jul 21, 2023
d4e1c3a
Add tb to Expr generated from names
dream189free Jul 21, 2023
9ede3a1
Try to pass debuginfo to FrontendIfStmt
dream189free Jul 21, 2023
b15f0b2
Pass debug info to FrontendForStmt from Python ast transformer
dream189free Jul 21, 2023
3903920
Debuginfo pssing for FrontendSnodeOpStmt
dream189free Jul 21, 2023
34776d0
Pass debuginfo to RandExpr and RandStmt
dream189free Jul 21, 2023
d7710c3
Pass debuginfo to ArgloadStmt
dream189free Jul 21, 2023
93d6865
Pass DebugInfo to AssertStmt
dream189free Jul 21, 2023
d5a7380
Try to pass debuginfo for FrontendFuncDefStmt
dream189free Jul 21, 2023
0849c5b
Fix error in default paramter
dream189free Jul 21, 2023
2861e84
Fix error on missing dbg_info for build_While
dream189free Jul 21, 2023
aafd2a5
Revert "Try to pass debuginfo for FrontendFuncDefStmt"
dream189free Jul 21, 2023
0d0a29d
Passs debuginfo for FrontendExternalFuncStmt
dream189free Jul 21, 2023
94dc237
Pass DebugInfo for FrontendAllocaStmt
dream189free Jul 21, 2023
3257700
Fix issue in FrontendAssertStmt
dream189free Jul 21, 2023
4a4f1b1
Fix issue in FrontendAssignStmt
dream189free Jul 21, 2023
1ad3fd9
Fix issue in FrontendIfStmt
dream189free Jul 21, 2023
a192184
Pass DebugInfo for FrontendPrintStmt
dream189free Jul 21, 2023
f6431f0
Pass DebugInfo for FrontendBreakStmt
dream189free Jul 21, 2023
182d9c9
Fix code format in FrontAssignStmt
dream189free Jul 21, 2023
cda4110
Pass DebugInfo for FrontendContinueStmt
dream189free Jul 21, 2023
31ccf0e
Pass DebugInfo for FrontendWhileStmt
dream189free Jul 21, 2023
fbcbf5d
Pass DebugInfo for FrontendReturnStmt
dream189free Jul 21, 2023
85869be
Fix error
dream189free Jul 21, 2023
be3d5cb
Revert change to clangpp candidate
dream189free Jul 21, 2023
41b5f2f
Merge remote-tracking branch 'origin/master' into error-emitter-5
dream189free Jul 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Pass debug info to FrontendForStmt from Python ast transformer
  • Loading branch information
dream189free committed Jul 21, 2023
commit b15f0b2494267040c7479e0a8a18c0c6bd4914d1
12 changes: 8 additions & 4 deletions python/taichi/lang/ast/ast_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 1277,8 @@ def build_range_for(ctx, node):
begin = ti_ops.cast(expr.Expr(0), primitive_types.i32)
end = ti_ops.cast(end_expr, primitive_types.i32)

ctx.ast_builder.begin_frontend_range_for(loop_var.ptr, begin.ptr, end.ptr)
for_di = _ti_core.DebugInfo(ctx.get_pos_info(node))
ctx.ast_builder.begin_frontend_range_for(loop_var.ptr, begin.ptr, end.ptr, for_di)
build_stmts(ctx, node.body)
ctx.ast_builder.end_frontend_range_for()
return None
Expand All @@ -1292,7 1293,8 @@ def build_ndrange_for(ctx, node):
primitive_types.i32,
)
ndrange_loop_var = expr.Expr(ctx.ast_builder.make_id_expr(""))
ctx.ast_builder.begin_frontend_range_for(ndrange_loop_var.ptr, ndrange_begin.ptr, ndrange_end.ptr)
for_di = _ti_core.DebugInfo(ctx.get_pos_info(node))
ctx.ast_builder.begin_frontend_range_for(ndrange_loop_var.ptr, ndrange_begin.ptr, ndrange_end.ptr, for_di)
I = impl.expr_init(ndrange_loop_var)
targets = ASTTransformer.get_for_loop_targets(node)
if len(targets) != len(ndrange_var.dimensions):
Expand Down Expand Up @@ -1334,7 1336,8 @@ def build_grouped_ndrange_for(ctx, node):
primitive_types.i32,
)
ndrange_loop_var = expr.Expr(ctx.ast_builder.make_id_expr(""))
ctx.ast_builder.begin_frontend_range_for(ndrange_loop_var.ptr, ndrange_begin.ptr, ndrange_end.ptr)
for_di = _ti_core.DebugInfo(ctx.get_pos_info(node))
ctx.ast_builder.begin_frontend_range_for(ndrange_loop_var.ptr, ndrange_begin.ptr, ndrange_end.ptr, for_di)

targets = ASTTransformer.get_for_loop_targets(node)
if len(targets) != 1:
Expand Down Expand Up @@ -1425,7 1428,8 @@ def build_nested_mesh_for(ctx, node):
ctx.create_variable(loop_name, loop_var)
begin = expr.Expr(0)
end = ti_ops.cast(node.iter.ptr.size, primitive_types.i32)
ctx.ast_builder.begin_frontend_range_for(loop_var.ptr, begin.ptr, end.ptr)
for_di = _ti_core.DebugInfo(ctx.get_pos_info(node))
ctx.ast_builder.begin_frontend_range_for(loop_var.ptr, begin.ptr, end.ptr, for_di)
entry_expr = _ti_core.get_relation_access(
ctx.mesh.mesh_ptr,
node.iter.ptr.from_index.ptr,
Expand Down
30 changes: 18 additions & 12 deletions taichi/ir/frontend_ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 59,19 @@ FrontendIfStmt::FrontendIfStmt(const FrontendIfStmt &o)
FrontendForStmt::FrontendForStmt(const ExprGroup &loop_vars,
SNode *snode,
Arch arch,
const ForLoopConfig &config)
: snode(snode) {
const ForLoopConfig &config,
const DebugInfo &dbg_info)
: Stmt(dbg_info), snode(snode) {
init_config(arch, config);
init_loop_vars(loop_vars);
}

FrontendForStmt::FrontendForStmt(const ExprGroup &loop_vars,
const Expr &external_tensor,
Arch arch,
const ForLoopConfig &config)
: external_tensor(external_tensor) {
const ForLoopConfig &config,
const DebugInfo &dbg_info)
: Stmt(dbg_info), external_tensor(external_tensor) {
init_config(arch, config);
init_loop_vars(loop_vars);
}
Expand All @@ -78,8 80,9 @@ FrontendForStmt::FrontendForStmt(const ExprGroup &loop_vars,
const mesh::MeshPtr &mesh,
const mesh::MeshElementType &element_type,
Arch arch,
const ForLoopConfig &config)
: mesh(mesh.ptr.get()), element_type(element_type) {
const ForLoopConfig &config,
const DebugInfo &dbg_info)
: Stmt(dbg_info), mesh(mesh.ptr.get()), element_type(element_type) {
init_config(arch, config);
init_loop_vars(loop_vars);
}
Expand All @@ -88,14 91,16 @@ FrontendForStmt::FrontendForStmt(const Expr &loop_var,
const Expr &begin,
const Expr &end,
Arch arch,
const ForLoopConfig &config)
: begin(begin), end(end) {
const ForLoopConfig &config,
const DebugInfo &dbg_info)
: Stmt(dbg_info), begin(begin), end(end) {
init_config(arch, config);
add_loop_var(loop_var);
}

FrontendForStmt::FrontendForStmt(const FrontendForStmt &o)
: snode(o.snode),
: Stmt(o.dbg_info),
snode(o.snode),
external_tensor(o.external_tensor),
mesh(o.mesh),
element_type(o.element_type),
Expand Down Expand Up @@ -1619,9 1624,10 @@ void ASTBuilder::create_assert_stmt(const Expr &cond,

void ASTBuilder::begin_frontend_range_for(const Expr &i,
const Expr &s,
const Expr &e) {
auto stmt_unique =
std::make_unique<FrontendForStmt>(i, s, e, arch_, for_loop_dec_.config);
const Expr &e,
const DebugInfo &dbg_info) {
auto stmt_unique = std::make_unique<FrontendForStmt>(
i, s, e, arch_, for_loop_dec_.config, dbg_info);
auto stmt = stmt_unique.get();
this->insert(std::move(stmt_unique));
this->create_scope(stmt->body,
Expand Down
17 changes: 12 additions & 5 deletions taichi/ir/frontend_ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,24 201,28 @@ class FrontendForStmt : public Stmt {
FrontendForStmt(const ExprGroup &loop_vars,
SNode *snode,
Arch arch,
const ForLoopConfig &config);
const ForLoopConfig &config,
const DebugInfo &dbg_info = DebugInfo());

FrontendForStmt(const ExprGroup &loop_vars,
const Expr &external_tensor,
Arch arch,
const ForLoopConfig &config);
const ForLoopConfig &config,
const DebugInfo &dbg_info = DebugInfo());

FrontendForStmt(const ExprGroup &loop_vars,
const mesh::MeshPtr &mesh,
const mesh::MeshElementType &element_type,
Arch arch,
const ForLoopConfig &config);
const ForLoopConfig &config,
const DebugInfo &dbg_info = DebugInfo());

FrontendForStmt(const Expr &loop_var,
const Expr &begin,
const Expr &end,
Arch arch,
const ForLoopConfig &config);
const ForLoopConfig &config,
const DebugInfo &dbg_info = DebugInfo());

bool is_container_statement() const override {
return true;
Expand Down Expand Up @@ -1042,7 1046,10 @@ class ASTBuilder {
void create_assert_stmt(const Expr &cond,
const std::string &msg,
const std::vector<Expr> &args);
void begin_frontend_range_for(const Expr &i, const Expr &s, const Expr &e);
void begin_frontend_range_for(const Expr &i,
const Expr &s,
const Expr &e,
const DebugInfo &dbg_info = DebugInfo());
void begin_frontend_struct_for_on_snode(const ExprGroup &loop_vars,
SNode *snode);
void begin_frontend_struct_for_on_external_tensor(
Expand Down