Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 32153e86262d9998240f5dcec6e2b38d71b28130 1 parent f61f94e
Colin Benner authored December 31, 2011

Showing 1 changed file with 2 additions and 4 deletions. Show diff stats Hide diff stats

  1. 6  src/asmcomp/llvmcompile.ml
6  src/asmcomp/llvmcompile.ml
@@ -333,16 +333,14 @@ let rec helper in_tail_position in_try_block instr =
333 333
       let arr = helper false in_try_block arr in
334 334
       let index = helper false in_try_block index in
335 335
       assert (typeof arr <> Void);
336  
-      let header = getelementptr (cast arr addr_type) (Lconst("-" ^ string_of_int size_addr, int_type)) in
337  
-      let length = load header in
338  
-      let cond = comp "icmp ule" (typeof length) index length in
  336
+      let cond = comp "icmp ule" (typeof index) arr index in
339 337
       let c = c () in
340 338
       add_function (addr_type, "ccc", "caml_ml_array_bound_error", []);
341 339
       Lcomment "checking bounds..."
342 340
       @@ Lbr_cond(cond, "out_of_bounds" ^ c, "ok" ^ c)
343 341
       @@ Llabel ("out_of_bounds" ^ c)
344 342
       @@ call Void (Lvar("@caml_ml_array_bound_error",Any)) []
345  
-      @@ Lbr ("ok" ^ c)
  343
+      @@ Lunreachable
346 344
       @@ Llabel ("ok" ^ c)
347 345
   | Cop(Ccheckbound _, _) -> error "not implemented: checkound with #args != 2"
348 346
   | Cop(op, exprs) -> compile_operation in_try_block op exprs

0 notes on commit 32153e8

Please sign in to comment.
Something went wrong with that request. Please try again.