From a7b51767d9435caf8b71aef1485d486f147d98b0 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Sat, 27 Aug 2016 22:46:45 +0800 Subject: [PATCH] Delete boundscheck handling from codegen --- src/codegen.cpp | 59 +++++-------------------------------------------- 1 file changed, 6 insertions(+), 53 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index c58a7a84206c52..8d9f29d663600e 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -4498,18 +4498,13 @@ static std::unique_ptr emit_function(jl_lambda_info_t *lam, jl_llvm_func DebugLoc loc; StringRef file; ssize_t line; - bool enabled; bool is_inbounds; bool loc_changed; bool is_poploc; }; std::vector stmtprops(stmtslen); std::vector DI_stack; - std::vector boundsCheck_stack{false}; std::vector inbounds_stack{false}; - auto is_bounds_check_block = [&] () { - return !boundsCheck_stack.empty() && boundsCheck_stack.back(); - }; auto is_inbounds = [&] () { // inbounds rule is either of top two values on inbounds stack are true size_t sz = inbounds_stack.size(); @@ -4518,7 +4513,7 @@ static std::unique_ptr emit_function(jl_lambda_info_t *lam, jl_llvm_func inbounds |= inbounds_stack[sz - 2]; return inbounds; }; - StmtProp cur_prop{topdebugloc, filename, toplineno, true, false, true, false}; + StmtProp cur_prop{topdebugloc, filename, toplineno, false, true, false}; for (i = 0; i < stmtslen; i++) { cur_prop.loc_changed = false; cur_prop.is_poploc = false; @@ -4628,64 +4623,26 @@ static std::unique_ptr emit_function(jl_lambda_info_t *lam, jl_llvm_func } if (expr) { jl_value_t **args = (jl_value_t**)jl_array_data(expr->args); - if (expr->head == boundscheck_sym) { - if (jl_array_len(expr->args) > 0) { - jl_value_t *arg = args[0]; - if (arg == jl_true) { - boundsCheck_stack.push_back(true); - } - else if (arg == jl_false) { - boundsCheck_stack.push_back(false); - } - else { - if (!boundsCheck_stack.empty()) { - boundsCheck_stack.pop_back(); - } - } - } - } - else if (cur_prop.enabled && expr->head == inbounds_sym) { + if (expr->head == inbounds_sym) { // manipulate inbounds stack - // note that when entering an inbounds context, we must also update - // the boundsCheck context to be false if (jl_array_len(expr->args) > 0) { jl_value_t *arg = args[0]; if (arg == jl_true) { inbounds_stack.push_back(true); - boundsCheck_stack.push_back(false); } else if (arg == jl_false) { inbounds_stack.push_back(false); - boundsCheck_stack.push_back(false); } - else { - if (!inbounds_stack.empty()) - inbounds_stack.pop_back(); - if (!boundsCheck_stack.empty()) - boundsCheck_stack.pop_back(); + else if (!inbounds_stack.empty()) { + inbounds_stack.pop_back(); } } } } - bool is_ib = is_inbounds(); - if (is_ib && is_bounds_check_block() && - jl_options.check_bounds != JL_OPTIONS_CHECK_BOUNDS_ON) { - // elide bounds check blocks in inbounds context - cur_prop.enabled = false; - } - else if (is_bounds_check_block() && - jl_options.check_bounds == JL_OPTIONS_CHECK_BOUNDS_OFF) { - // elide bounds check blocks when turned off by options - cur_prop.enabled = false; - } - else { - cur_prop.enabled = true; - } - cur_prop.is_inbounds = is_ib; + cur_prop.is_inbounds = is_inbounds(); stmtprops[i] = cur_prop; } DI_stack.clear(); - boundsCheck_stack.clear(); inbounds_stack.clear(); // step 12. Do codegen in control flow order @@ -4772,7 +4729,7 @@ static std::unique_ptr emit_function(jl_lambda_info_t *lam, jl_llvm_func if (ctx.debug_enabled) builder.SetCurrentDebugLocation(props.loc); // Disable coverage for pop_loc, it doesn't start a new expression - if (do_coverage && props.enabled && !props.is_poploc) { + if (do_coverage && !props.is_poploc) { coverageVisitLine(props.file, props.line); } } @@ -4785,10 +4742,6 @@ static std::unique_ptr emit_function(jl_lambda_info_t *lam, jl_llvm_func handle_label(lname, true); continue; } - if (!props.enabled) { - find_next_stmt(cursor + 1); - continue; - } if (expr && expr->head == return_sym) { bool retboxed = false; Type *retty;