[PATCH] D101701: [nofree] Refine concurrency requirements

Nuno Lopes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 9 15:17:14 PDT 2021


nlopes added a comment.

@jdoerfert a function that syncs with another thread may not free anything itself and the other thread may not free anything either.
If you require an optimization to have nofree + nosync in a call to preserve dereferenceability then you can't optimize this case.

That said, I had a thought last night and it isn't clear to me what to do with escaped pointers. On one hand it's nice for the optimizers if nofree implies escaped pointers aren't freed. This, however, makes inferring nofree harder. Functions that sync with other threads can't really be marked nofree without IPA. Essentially it degenerates in your concern, that nofree then implies nosync (in practice). However, it allows improved precision in theory (in case someone cares and implements an IPA).

Another possibility is to restrict nofree to unescaped pointers. But that degenerates in tagging function arguments with nofree, as unescaped can't be freed anyway.

The current proposal leaves room for improvement in the future if someone cares about multi-threaded programs and implements an IPA. Since it doesn't seem to impose any major pain in the implementation, it seems to be the best option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101701



More information about the llvm-commits mailing list