[LLVMdev] Structure Returns

Jeffrey Yasskin jyasskin at google.com
Thu Jun 25 11:37:04 PDT 2009

On Thu, Jun 25, 2009 at 10:49 AM, kapil anand<kapilanand2 at gmail.com> wrote:
> Hi,
> In my LLVM IR I am returning a structure from a function but it gave me an
> assertion failure when I was trying to compile the resulting bitcode.
> Specifically, I had following function definition
> define {i32,i32,i32} @func(i32 a)
> {
> .....
> ret {i32,i32,i32} %retStruct
> }
> llc gave me following assertion failure:
> Return operand#2 has unhandled type i32  in AnalyzeReturn function
> On digging out from LLVM website, I found
> "Note that the code generator does not yet fully support large return
> values. The specific sizes that are currently supported are dependent on the
> target. For integers, on 32-bit targets the limit is often 64 bits, and on
> 64-bit targets the limit is often 128 bits. For aggregate types, the current
> limits are dependent on the element types; for example targets are often
> limited to 2 total integer elements and 2 total floating-point elements."
> So, does this mean that I can't have a return type with more than two
> integers? Is there any other way to support longer return structure?

That's what it means (at least until someone like you contributes a
patch to support larger return structs). To work around it, imitate
what the C compiler does.

Try typing:

struct Big {
 int a, b, c;

struct Big foo() {
  struct Big result = {1, 2, 3};
  return result;

into http://llvm.org/demo/.

More information about the llvm-dev mailing list