diff options
| author | gingerBill <bill@gingerbill.org> | 2018-01-18 12:22:27 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-01-18 12:22:27 +0000 |
| commit | add53228b2ee93f7374a815ce1c4e5a86b7b9d28 (patch) | |
| tree | f18cf032c65be941c8f03d9072286810c0bede93 /src | |
| parent | d90008cc524ae7075a91fa763def3918adb61fc6 (diff) | |
`-no-bounds-check`
Diffstat (limited to 'src')
| -rw-r--r-- | src/build_settings.cpp | 1 | ||||
| -rw-r--r-- | src/ir.cpp | 12 | ||||
| -rw-r--r-- | src/main.cpp | 6 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 5948bd0f4..e0bc71949 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -23,6 +23,7 @@ struct BuildContext { bool show_timings; bool keep_temp_files; bool debug; + bool no_bounds_check; gbAffinity affinity; isize thread_count; diff --git a/src/ir.cpp b/src/ir.cpp index ecaa5bbd4..dae3e94d6 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -3585,6 +3585,9 @@ irValue *ir_emit_logical_binary_expr(irProcedure *proc, AstNode *expr) { void ir_emit_bounds_check(irProcedure *proc, Token token, irValue *index, irValue *len) { + if (build_context.no_bounds_check) { + return; + } if ((proc->module->stmt_state_flags & StmtStateFlag_no_bounds_check) != 0) { return; } @@ -3610,6 +3613,9 @@ void ir_emit_bounds_check(irProcedure *proc, Token token, irValue *index, irValu } void ir_emit_slice_bounds_check(irProcedure *proc, Token token, irValue *low, irValue *high, bool is_substring) { + if (build_context.no_bounds_check) { + return; + } if ((proc->module->stmt_state_flags & StmtStateFlag_no_bounds_check) != 0) { return; } @@ -3628,11 +3634,13 @@ void ir_emit_slice_bounds_check(irProcedure *proc, Token token, irValue *low, ir args[3] = low; args[4] = high; - char const *func = is_substring ? "__substring_expr_error" : "__slice_expr_error"; - ir_emit_global_call(proc, func, args, 5); + ir_emit_global_call(proc, "__slice_expr_error", args, 5); } void ir_emit_dynamic_array_bounds_check(irProcedure *proc, Token token, irValue *low, irValue *high, irValue *max) { + if (build_context.no_bounds_check) { + return; + } if ((proc->module->stmt_state_flags & StmtStateFlag_no_bounds_check) != 0) { return; } diff --git a/src/main.cpp b/src/main.cpp index a31821e9b..ec9d8b768 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -212,6 +212,7 @@ enum BuildFlagKind { BuildFlag_Debug, BuildFlag_CrossCompile, BuildFlag_CrossLibDir, + BuildFlag_NoBoundsCheck, BuildFlag_COUNT, }; @@ -250,6 +251,7 @@ bool parse_build_flags(Array<String> args) { add_flag(&build_flags, BuildFlag_Debug, str_lit("debug"), BuildFlagParam_None); add_flag(&build_flags, BuildFlag_CrossCompile, str_lit("cross-compile"), BuildFlagParam_String); add_flag(&build_flags, BuildFlag_CrossLibDir, str_lit("cross-lib-dir"), BuildFlagParam_String); + add_flag(&build_flags, BuildFlag_NoBoundsCheck, str_lit("no-bounds-check"), BuildFlagParam_None); GB_ASSERT(args.count >= 3); @@ -505,6 +507,10 @@ bool parse_build_flags(Array<String> args) { case BuildFlag_Debug: build_context.debug = true; break; + + case BuildFlag_NoBoundsCheck: + build_context.no_bounds_check = true; + break; } } |