[LLVMdev] Generating DWARF information that pretends an outparam is the return value

Josh Matthews josh at joshmatthews.net
Sun Dec 4 21:33:56 PST 2011

The Rust compiler defines all functions as returning void, with the
first parameter being an outparam of the declared return type, ie.

fn foo2() -> int { ret 5; }


define void @_ZN4foo217_5cb557d30658848cE(i64*, { i64, { %tydesc*, i1,
{} } }*) uwtable {
  store i64 5, i64* %0
  ret void

I'm working on generating debug information for Rust, and I'm
currently stumped on how to generate DWARF output via LLVM that will
correctly represent this (eg. when exiting from foo2(), I'd like to
see "Value returns is $1 = 5"). I'm generating debug metadata nodes
directly instead of using DIBuilder since it doesn't seem to
encapsulate situations like this. Any thoughts? Apologies if this is
too esoteric for the general LLVM community, but there's a seeming
dearth of information about things like DW_TAG_return_variable on the
wider internet.


More information about the llvm-dev mailing list