static void sanitize_assert(const out_val *cond, out_ctx *octx, const char *desc) { out_blk *land = out_blk_new(octx, "san_end"); out_blk *blk_undef = out_blk_new(octx, "san_bad"); out_ctrl_branch(octx, cond, land, blk_undef); out_current_blk(octx, blk_undef); out_comment(octx, "sanitizer for %s", desc); if(cc1_sanitize_handler_fn) { type *voidty = type_nav_btype(cc1_type_nav, type_void); funcargs *args = funcargs_new(); type *fnty_noptr = type_func_of(voidty, args, NULL); type *fnty_ptr = type_ptr_to(fnty_noptr); char *mangled = func_mangle(cc1_sanitize_handler_fn, fnty_noptr); const out_val *fn = out_new_lbl(octx, fnty_ptr, mangled, 0); out_val_release(octx, out_call(octx, fn, NULL, fnty_ptr)); if(mangled != cc1_sanitize_handler_fn) free(mangled); } out_ctrl_end_undefined(octx); out_current_blk(octx, land); }
const out_val *gen_expr_funcall(const expr *e, out_ctx *octx) { const out_val *fn_ret; if(0){ out_comment(octx, "start manual __asm__"); ICE("same"); #if 0 fprintf(cc_out[SECTION_TEXT], "%s\n", e->funcargs[0]->data_store->data.str); #endif out_comment(octx, "end manual __asm__"); }else{ /* continue with normal funcall */ const out_val *fn, **args = NULL; fn = gen_expr(e->expr, octx); if(e->funcargs){ expr **aiter; for(aiter = e->funcargs; *aiter; aiter++){ expr *earg = *aiter; const out_val *arg; /* should be of size int or larger (for integral types) * or double (for floating types) */ arg = gen_expr(earg, octx); dynarray_add(&args, arg); } } /* consumes fn and args */ fn_ret = gen_call(e->expr, NULL, fn, args, octx, &e->expr->where); dynarray_free(const out_val **, args, NULL); if(!expr_func_passable(GEN_CONST_CAST(expr *, e))) out_ctrl_end_undefined(octx); } return fn_ret; }