Return on nocapture pointer

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

I believe it is invalid. It’s making a copy that outlives the call. I don’t think functionattrs will infer this, for example.

Yes, it includes returning the pointer. The code below is invalid. The return value outlives the callee itself. Correct. -Hal

Thanks guys.
Do you it make sense to extend the definition in LangRef? If so I will be happy to upload a patch.

Piotr

Hi Piotr,

Thanks guys.
Do you it make sense to extend the definition in LangRef?

If you're asking if it makes sense to allow nocapture on returned
arguments, then I don't think it make sense. Right now we assume a
pointer that only has nocapture uses is not captured. That will not
be true with the spec change you're proposing.

-- Sanjoy

Hi Piotr,

> Thanks guys.
> Do you it make sense to extend the definition in LangRef?

If you're asking if it makes sense to allow nocapture on returned
arguments, then I don't think it make sense. Right now we assume a
pointer that only has nocapture uses is not captured. That will not
be true with the spec change you're proposing.

No, I was making sure if I could mark invariant.group.barrier as

nocapture, but since barrier returns the pointer it takes, I can't do it.

Piotr