<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On 2008-03-15, at 10:09, Jon Harrop wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">There is an overhead in building these intermediate data structures<br></blockquote><div><br class="webkit-block-placeholder"></div><div>Converting enums to tags, yes. Phantom types no.</div><br><blockquote type="cite">Several ops can only appear either at the start (e.g. phi node) or end (e.g. unconditional branch) of a block. These should be taken out of the set of general ops and blocks should have different types of start and end:<br><br> module Block = struct<br> type start = [ `None | Phi of ... ]<br> type end = [ `Return of Op.t | `Branch of Block.t ref ]<br> type t = start * Op.t list * end<br> end<br></blockquote><div><br class="webkit-block-placeholder"></div><div>You're reinventing the object model here. There's no reason you shouldn't build your own IR separate from LLVM's, though. Just write an output algorithm to convert your IR into an llmodule using the bindings so you can interoperate with the LLVM infrastructure.</div><br><blockquote type="cite">Another practical advance I'd like to see is the LLVM bindings catching exceptions on the C++ side and reraising them in OCaml. At the moment you cannot get a stacktrace from an OCaml program that dies due to an exception being raised in LLVM which is a bit frustrating because you have to guess where the program died in the OCaml code.<br></blockquote><div><br class="webkit-block-placeholder"></div><div>LLVM doesn't use exceptions. assert() failures just print to stderr and call abort() [= exit(1)], so they can't be caught. Even if they could, the stack couldn't be unwound (because the C++ exception tables are not emitted), so the program would leak memory and leave leave the heap in inconsistent state, inevitably leading to crashes. So this isn't going to happen.</div><div><br class="webkit-block-placeholder"></div><div>I'm not disputing that this is a pain point, however. I wouldn't be opposed to patches which check preconditions in the ocaml bindings layer and raise exceptions <i>before</i> calling into the C bindings.</div></div><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><br class="khtml-block-placeholder"></div>— Gordon<br class="Apple-interchange-newline"></span></span></span></span></span></div></span> </div><br></body></html>