[LLVMdev] Changes between 2.6 and 2.7: SSA Verifier and visitFreeInst

Duncan Sands baldrick at free.fr
Mon Mar 8 00:16:42 PST 2010


Hi Jianzhou Zhao,

> Another question is about 'ret'.
> http://llvm.org/docs/LangRef.html#i_ret gives the syntax:
>     ret<type>  <value>        ; Return a value from a non-void function
>     ret void                 ; Return from void function
> In the case when the return type is not void, it returns
> a single value. But if I am looking into the code,
> the Verifier also allows 'multi returned values' if the return
> type is of structure or array, while there is not interface
> in 'ReturnInst' to create a multi-value 'ret'. Is it only for
> the ll code that was generated by an old version LLVM
> which had still supported 'multi-return'.

it used to be the case that you could not have registers of struct or
array type, and thus you could not return structs or arrays from functions.
A special syntax was created to allow you to nonetheless return multiple
values from a function.  However the restriction on registers was later
removed: you can now have registers of struct or array type, and return
them from functions.  This made the special support for multiple return
values obsolete: nowadays you can just return a struct/array.  There is
no need for a special ReturnInst, since scalar and struct/array values
are handled the same way.

> The comments in 'Verifier' say this 'multi-return' verification
> feature may be removed from LLVM 3.0. So If I am generating
> 'ret' with multi values, will that be a verification error
> when LLVM 3.0 releases?

If you are returning a struct or array, then that will continue to be
supported, since this is now the standard way of doing things.  As a
general rule, LLVM is backwards compatible, so even if you are using the
obsolete special multiple return values syntax, then it should continue
to be supported for ever (though you may be required to run a special
tool to upgrade your bitcode).

Ciao,

Duncan.



More information about the llvm-dev mailing list