Hi, I have a question about semantics of nocapture attribute: "This indicates that the callee does not make any copies of the pointer that outlive the callee itself. " Is returing a pointer considered outliving callee? For example is this code valid: define i8* @foo(i8* nocapture %p) ret i8* %p } The documentation also mention that " This is not a valid attribute for return values.", but I interpret that it is is about this case: declare i8* nocapture @bar(i8* %p) Piotr -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170428/daaadf50/attachment.html>
I believe it is invalid. It's making a copy that outlives the call. I don't think functionattrs will infer this, for example. On Fri, Apr 28, 2017 at 8:22 AM, Piotr Padlewski via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi, > I have a question about semantics of nocapture attribute: > "This indicates that the callee does not make any copies of the pointer > that outlive the callee itself. " > Is returing a pointer considered outliving callee? For example is this > code valid: > > define i8* @foo(i8* nocapture %p) > ret i8* %p > } > > The documentation also mention that " This is not a valid attribute for > return values.", but I interpret that it is is about this case: > > declare i8* nocapture @bar(i8* %p) > > Piotr > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170428/cafdb5b9/attachment.html>
On 04/28/2017 10:22 AM, Piotr Padlewski via llvm-dev wrote:> Hi, > I have a question about semantics of nocapture attribute: > "This indicates that the callee does not make any copies of the > pointer that outlive the callee itself. " > Is returing a pointer considered outliving callee? For example is this > code valid:Yes, it includes returning the pointer. The code below is invalid. The return value outlives the callee itself.> > define i8* @foo(i8* nocapture %p) > ret i8* %p > } > > The documentation also mention that "This is not a valid attribute for > return values.", but I interpret that it is is about this case: > > declare i8* nocapture @bar(i8* %p)Correct. -Hal> > Piotr > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-- Hal Finkel Lead, Compiler Technology and Programming Languages Leadership Computing Facility Argonne National Laboratory -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170428/be36d0cf/attachment.html>
Thanks guys. Do you it make sense to extend the definition in LangRef? If so I will be happy to upload a patch. Piotr 2017-04-28 17:58 GMT+02:00 Hal Finkel <hfinkel at anl.gov>:> > > On 04/28/2017 10:22 AM, Piotr Padlewski via llvm-dev wrote: > > Hi, > I have a question about semantics of nocapture attribute: > "This indicates that the callee does not make any copies of the pointer > that outlive the callee itself. " > Is returing a pointer considered outliving callee? For example is this > code valid: > > > Yes, it includes returning the pointer. The code below is invalid. The > return value outlives the callee itself. > > > define i8* @foo(i8* nocapture %p) > ret i8* %p > } > > The documentation also mention that " This is not a valid attribute for > return values.", but I interpret that it is is about this case: > > declare i8* nocapture @bar(i8* %p) > > > Correct. > > -Hal > > > Piotr > > > _______________________________________________ > LLVM Developers mailing listllvm-dev at lists.llvm.orghttp://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > > -- > Hal Finkel > Lead, Compiler Technology and Programming Languages > Leadership Computing Facility > Argonne National Laboratory > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170428/afbfbdaf/attachment.html>
Maybe Matching Threads
- Return on nocapture pointer
- [LLVMdev] Meaning of the nocapture attribute (possible bug?)
- [LLVMdev] Meaning of the nocapture attribute (possible bug?)
- [LLVMdev] Meaning of the nocapture attribute (possible bug?)
- [LLVMdev] Meaning of the nocapture attribute (possible bug?)