[PATCH] D94386: [LangRef] State that a nocapture pointer cannot be returned

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 12 04:53:09 PST 2021


aqjune added a comment.

In D94386#2490154 <https://reviews.llvm.org/D94386#2490154>, @jdoerfert wrote:

> Should we add the, "if broken -> UB!" clause while we are here?

That's a good point, but I think there are a few candidate semantics and I'm not sure which one is the best.
It can be (1) UB, or (2) the stored pointer magically turns into poison when it returns. Also, it isn't certain when the program should raise UB (during the execution of the callee, or when the callee finally returns).
Diving into this issue more, it can be indirectly captured using ptr-int casts:

  if (p == 0x100) {
    escape ((i8*)0x100);
  }

So, TBH, I'd like to make this patch just a simple step clarifying that nocapture pointer cannot be returned. :/ Making a further step might require as much discussion as lifetime/nonnull.
(BTW, for the lifetime patch, I'm still interested in making further progress; I'm busy until the end of Jan, I'll restart working on it after the busy thing is done.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94386/new/

https://reviews.llvm.org/D94386



More information about the llvm-commits mailing list