Permalink
Browse files

Fixed the bounds-checking code (to some degree...)

  • Loading branch information...
1 parent f61f94e commit 32153e86262d9998240f5dcec6e2b38d71b28130 @colinbenner committed Dec 31, 2011
Showing with 2 additions and 4 deletions.
  1. +2 −4 src/asmcomp/llvmcompile.ml
@@ -333,16 +333,14 @@ let rec helper in_tail_position in_try_block instr =
let arr = helper false in_try_block arr in
let index = helper false in_try_block index in
assert (typeof arr <> Void);
- let header = getelementptr (cast arr addr_type) (Lconst("-" ^ string_of_int size_addr, int_type)) in
- let length = load header in
- let cond = comp "icmp ule" (typeof length) index length in
+ let cond = comp "icmp ule" (typeof index) arr index in
let c = c () in
add_function (addr_type, "ccc", "caml_ml_array_bound_error", []);
Lcomment "checking bounds..."
@@ Lbr_cond(cond, "out_of_bounds" ^ c, "ok" ^ c)
@@ Llabel ("out_of_bounds" ^ c)
@@ call Void (Lvar("@caml_ml_array_bound_error",Any)) []
- @@ Lbr ("ok" ^ c)
+ @@ Lunreachable
@@ Llabel ("ok" ^ c)
| Cop(Ccheckbound _, _) -> error "not implemented: checkound with #args != 2"
| Cop(op, exprs) -> compile_operation in_try_block op exprs

0 comments on commit 32153e8

Please sign in to comment.