From 7eb6af1d3e92510cb558d43ac80c45964f183bb7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 9 Apr 2016 16:52:52 -0700 Subject: add @breakpoint() --- src/codegen.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index dbab8ddd9b..89bfc4d294 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -513,6 +513,8 @@ static LLVMValueRef gen_builtin_fn_call_expr(CodeGen *g, AstNode *node) { return nullptr; case BuiltinFnIdErrName: return gen_err_name(g, node); + case BuiltinFnIdBreakpoint: + return LLVMBuildCall(g->builder, g->trap_fn_val, nullptr, 0, ""); } zig_unreachable(); } @@ -3790,9 +3792,15 @@ static BuiltinFnEntry *create_builtin_fn_with_arg_count(CodeGen *g, BuiltinFnId static void define_builtin_fns(CodeGen *g) { { + BuiltinFnEntry *builtin_fn = create_builtin_fn_with_arg_count(g, BuiltinFnIdBreakpoint, "breakpoint", 0); + builtin_fn->return_type = g->builtin_types.entry_void; + builtin_fn->ref_count = 1; + LLVMTypeRef fn_type = LLVMFunctionType(LLVMVoidType(), nullptr, 0, false); - g->trap_fn_val = LLVMAddFunction(g->module, "llvm.debugtrap", fn_type); - assert(LLVMGetIntrinsicID(g->trap_fn_val)); + builtin_fn->fn_val = LLVMAddFunction(g->module, "llvm.debugtrap", fn_type); + assert(LLVMGetIntrinsicID(builtin_fn->fn_val)); + + g->trap_fn_val = builtin_fn->fn_val; } { BuiltinFnEntry *builtin_fn = create_builtin_fn(g, BuiltinFnIdMemcpy, "memcpy"); -- cgit v1.2.3