Skip to content

Commit 72f1191

Browse files
committed
fix debugprintf in l2s
1 parent 27876af commit 72f1191

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/frontends/llvm/l2s_postprocess.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,22 @@ static const Node* process_op(Context* ctx, NodeClass op_class, String op_name,
109109
new->payload.constant.instruction = yield_values_and_wrap_in_block(bb, singleton(value));
110110
return new;
111111
}
112+
case PrimOp_TAG: {
113+
Nodes old_operands = node->payload.prim_op.operands;
114+
switch (node->payload.prim_op.op) {
115+
case debug_printf_op: {
116+
Nodes new_operands = rewrite_nodes(r, old_operands);
117+
String lit = get_string_literal(a, old_operands.nodes[0]);
118+
assert(lit && "debug_printf requires a string literal");
119+
new_operands = change_node_at_index(a, new_operands, 0, string_lit_helper(a, lit));
120+
// for (size_t i = 1; i < old_operands.count; i++)
121+
// new_operands[i] = infer(ctx, old_operands.nodes[i], NULL);
122+
return prim_op_helper(a, debug_printf_op, empty(a), new_operands);
123+
}
124+
default: break;
125+
}
126+
break;
127+
}
112128
case Function_TAG: {
113129
Context fn_ctx = *ctx;
114130
fn_ctx.curr_scope = new_scope(node);

0 commit comments

Comments
 (0)