[Openmp-commits] [PATCH] D72525: [LIBOMPTARGET] Do not increment/decrement the refcount for "declare target" objects

Jon Chesterfield via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Jan 13 08:31:26 PST 2020


JonChesterfield added a comment.

In D72525#1817204 <https://reviews.llvm.org/D72525#1817204>, @grokos wrote:

> but in such problematic code even a 64-bit counter could overflow. Actually the above example is taylor-made to intentionally make the refcount overflow.


Curiously enough, refcounts can't overflow when bit size matches or exceeds address space.

Each refcount increment indicates some live reference to the object which itself uses some space. So even if we were refcounting an object of size one, each time we copy that object (thus increment the refcount) we also need non-zero bytes of address space for the new reference to that object. That is, we run out of address space shortly before the refcount overflows, even in the most extreme case and disregarding the considerable time it takes to count to 2^48.

Unless it's a <=32 bit counter and we're using a 48 bit address space system, where repeatedly kicking the counter can overflow within a plausible length of time (iirc it's of the order of a few hours spinning on the counter).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72525





More information about the Openmp-commits mailing list