[LLVMdev] First-class aggregate semantics
dllaurence at dslextreme.com
Thu Jan 7 13:28:21 PST 2010
I think I'm missing something basic about the semantics of returning an
aggregate type (in my case, a structure) from a function. Returning a
structure containing only compile-time constants is simple enough. But
I don't quite get how this works with a struct composed at run-time. If
I constructed it on the stack with alloca, would I be letting a stack
variable escape to to a context where it doesn't exist if I return it?
Or does the return semantics guarantee it will be copied (or space
allocated in the caller) appropriately? Otherwise I should abandon the
idea of returning such a struct and simply pass in a pointer to space
allocated in the caller.
I think my confusion stems from thinking in terms of high-level
languages and not having done nearly enough assembly work to know what
LLVM really wants to do, and I'd be grateful for a clue about the
idiomatic way to do this.
More information about the llvm-dev