Skip to content

Commit 8e963f6

Browse files
committed
Add trace and trap helpers to trans for low level diagnostics.
1 parent dd3ed61 commit 8e963f6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/comp/middle/trans.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4186,6 +4186,24 @@ fn declare_intrinsics(ModuleRef llmod) -> hashmap[str,ValueRef] {
41864186
ret intrinsics;
41874187
}
41884188

4189+
4190+
fn trace_str(@block_ctxt cx, str s) {
4191+
trans_upcall(cx, "upcall_trace_str", vec(p2i(C_cstr(cx.fcx.ccx, s))));
4192+
}
4193+
4194+
fn trace_word(@block_ctxt cx, ValueRef v) {
4195+
trans_upcall(cx, "upcall_trace_word", vec(v));
4196+
}
4197+
4198+
fn trace_ptr(@block_ctxt cx, ValueRef v) {
4199+
trace_word(cx, cx.build.PtrToInt(v, T_int()));
4200+
}
4201+
4202+
fn trap(@block_ctxt bcx) {
4203+
let vec[ValueRef] v = vec();
4204+
bcx.build.Call(bcx.fcx.ccx.intrinsics.get("llvm.trap"), v);
4205+
}
4206+
41894207
fn check_module(ModuleRef llmod) {
41904208
auto pm = mk_pass_manager();
41914209
llvm.LLVMAddVerifierPass(pm.llpm);

0 commit comments

Comments
 (0)