[LLVMdev] Semantic of parameter attribute noalias

Eli Friedman eli.friedman at gmail.com
Fri Aug 22 14:28:15 PDT 2008


On Fri, Aug 22, 2008 at 9:45 AM,  <matthieu at illinois.edu> wrote:
> So here are my two questions:
> - What does "restrict" actually means in this case?

If I'm reading the standard correctly, "restrict" on a parameter
roughly means that if the current function, or any function it calls,
accesses memory through an pointer whose value depends on the value of
the parameter, all accesses must depend on the value of that pointer.

> - Should my interpretation of restrict being valid, does
> it however means "noalias" should be updated as well?

The documentation is a bit unclear, but I'm pretty sure the definition
is supposed to guarantee precisely the following: if P is a noalias
parameter, and Q is a pointer not derived from P, between the entry to
the function and the return from the function, alias(P,Q) is false.
What BasicAA implements fits this definition; I think the fact that
it's missing the case of a noalias argument and a non-noalias argument
is just an accident.

That said, I'm not sure if this is precisely equivalent to the C
version; the C definition of restrict means that it only kicks in if
there's a load from a restrict pointer, and the definition of noalias
and the BasicAA implementation make me think that it applies even if
there aren't any memory operations involved.

-Eli



More information about the llvm-dev mailing list