[LLVMdev] What does "noalias sret" mean?

Tim Northover t.p.northover at gmail.com
Wed Jul 15 21:08:56 PDT 2015


> Could you tell me why function "func" with a return value
> is changed to be one with a void return value and another
> more parameter %o. Does "noalias sret" play a special role?

Have you found the reference page for LLVM IR yet? It describes sret:
http://llvm.org/docs/LangRef.html

> What is the exact meaning of "noalias sret"?

The "sret" (struct-return) is the important one. When a struct gets
too big (as decided by the ABI writers) to be returned directly, what
often happens is that the caller has to allocate storage for the
object and pass this pointer to the function being called.

Because this demotion is often handled differently from a normal
argument (AArch64 requires register "X8" to be used; as I recall x86
requires the pointer to be re-returned) we need a special argument
attribute to mark this so that the correct code can be generated.

"noalias" is just an optimisation hint: because of how this argument
came to exist (allocated by the caller directly before the call), no
other pointer accessible to the function can alias it. This allows
some useful transformations in the mid-end.

Cheers.

Tim.



More information about the llvm-dev mailing list