[LLVMdev] ocaml+llvm

Gordon Henriksen gordonhenriksen at mac.com
Mon Aug 13 04:17:03 PDT 2007


Thanks for the quick reply, Anton.

On 2007-08-12, at 16:43, Anton Korobeynikov wrote:

> Hello, Gordon.
>
> Just a quick thinko (that's why I'm sending this e-mail personally):

No problem. I hope you don't mind me redirecting back to the list,  
though…

> maybe current infrastructure used for eh/debug info emission can be  
> extended to handle ocaml data?

Perhaps. I'm pretty sure the code to generate this stuff doesn't  
belong in LLVM proper like DWARF support does, though; this is not  
even a vague approximation of a standard. :)

> Now it emits just DWARF information. Probably, we can think about  
> extending it to emit some "random" information. For example, there  
> is a term "landing pad", which corresponds to catch-block in C++.  
> Internally, landing pad is just pair of labels plus some additional  
> info. Labels appears from lowering of invoke inst, maybe something  
> like this can be used to emit necessary information?

Oo, that sounds like the right track. Maybe I could tack an optional  
something onto the call/invoke instructions that says "export a  
return address label", like this:

     %tmp.1 = i8* call @_camlPervasives__print_endline_298(i8* % 
greeting.0) ret internal i8* @L103

And then adjust the code generators to insert the specified label.  
Afterwards, @L103 would be a normal constant and I could build the  
frame table as a plain old LLVM constant.

> Some amount of intrinsics plus additional lowering code.

I can think of two ways to use an intrinsic toward this end, both of  
which seem unfortunately flawed:

     ; Annotation on the call instruction.
     %tmp.1 = i8* call @_camlPervasives__print_endline_298(i8* % 
greeting.0)
     call void @llvm.var.annotate(i8* %tmp.1, i8* "L103", i8* null,  
i32 0)

The code generator can notice the annotation and insert the label.  
But… what if the callee had a void return type? There's no register  
to annotate.

     ; A freestanding call immediately following the call instruction.
     %tmp.1 = i8* call @_camlPervasives__print_endline_298(i8* % 
greeting.0)
     call void @llvm.pcmarker(i32 103)

The marker can just be lowered to a label. But… what about caller- 
save calling convention? The PC marker won't be on the right  
instruction. If I'm just imagining this problem, then this may be the  
solution to this problem.

> Even more, maybe some present functionaly can be trivially  
> extended, or annotation intrinsic used for this?

Hopefully Chris has something up his sleeve! I don't think  
llvm.var.annotate works, though as pointed out above.

— Gordon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070813/ba0100b3/attachment.html>


More information about the llvm-dev mailing list