sret
Sret, short for structure return, is a parameter attribute used in compiler intermediate representations (notably LLVM IR) to indicate how a function returns a value that is a structure or other large aggregate. When a function uses sret, the caller allocates memory for the return value and passes a pointer to that memory as the first argument. The callee then writes the result into that memory and returns (often as void).
In practice, sret changes the calling convention for large return types. Instead of returning the value in
define void @makePoint(%Point* sret %ret, i32 %x, i32 %y) {
%p0 = getelementptr %Point, %Point* %ret, i32 0, i32 0
%p1 = getelementptr %Point, %Point* %ret, i32 0, i32 1
}
This function writes the Point result to the memory pointed to by %ret. A caller would allocate
Sret is primarily a low-level concern of compilers and ABI compatibility, and is generally invisible to