[llvm-commits] [llvm] r61019 - in /llvm/trunk: docs/AliasAnalysis.html docs/LangRef.html include/llvm/Attributes.h lib/AsmParser/LLLexer.cpp lib/AsmParser/llvmAsmParser.y lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Writer/BitcodeWriter.cpp lib/VMCore/Attributes.cpp

Nick Lewycky nicholas at mxc.ca
Mon Dec 15 21:26:23 PST 2008

Duncan Sands wrote:
> Hi Nick,
>> Introducing nocapture, a parameter attribute for pointers to indicate that the
>> callee will not introduce any new aliases of that pointer.
> if I understand right, this attribute means that the pointer is only dereferenced:
> no bits of the pointer value itself are otherwise used or escape.
>> +    <dt><tt>nocapture</tt></dt>
>> +    <dd>This indicates that the callee does not make any copies of the pointer
>> +    that outlive the callee itself. This is not a valid attribute for return
>> +    values.</dd>
> I think you should mention that callee does not copy even one bit.  Because if
> it is allowed to, it is easy to construct examples where the whole pointer value
> escapes through multiple calls.

It's not allowed to. The pointer can be used, copied, etc., as much as 
you want by the callee and its tree of callees, so long as not one bit 
of the pointer is after the call has completed (so the copies made must 
be destroyed before returning).

I'm not sure I want to go into such detail in the LangRef. I think that 
if somebody really does write a function that leaks 1 bit of a pointer, 
marks it nocapture, then calls it in a loop, reconstitutes a pointer and 
makes a program that miscompiles, we can inform them that they have 
misused nocapture.

It's esoteric enough that I think explaining it in the LangRef will lead 
to more confusion, not more understanding. If you can come up with 
wording that would clarify the intent I think that'd be great, but I 
don't think it's needed.


More information about the llvm-commits mailing list