[LLVMdev] [Caml-list] Ocaml(opt) & llvm

Gordon Henriksen gordonhenriksen at mac.com
Thu Nov 29 07:37:32 PST 2007


On Nov 29, 2007, at 1:24, Chris Lattner <sabre at nondot.org> wrote:

>   int x = ...
>  try {
>    x++;
>    foo();
>
>    use (x);
>
>  } catch (...) {
>    print x;
>  }
>
> Because the 'throw' doesn't restore the callee-save registers as the
> stack is unwound, the compiler can't put X in a register across the x+
> + and use of x in the try block.

Actually, this is difficult to reproduce in Ocaml codes because Ocaml  
code is in a restricted SSA form:

(1) Mutable variables exist only in the heap: let x = 43 ref is  
literally shorthand for let x = { mutable contents = 43 }, which  
allocates a single-cell object on the heap. Arrays and strings (also  
imperative) are also restricted to the heap.
(2) Loop index variables from the for expression cannot escape.

Still, it could be significant after LLVM transformations.

-- Gordon



More information about the llvm-dev mailing list