[PATCH] D115274: [IR][RFC] Memory region declaration intrinsic

Clement Courbet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 8 04:07:12 PST 2021


courbet added inline comments.


================
Comment at: llvm/docs/LangRef.rst:20418
+as the argument. The second argument specifies the offset to the pointer (the
+first argument) at which the memory region begins. The third argument specifies
+the offset to the pointer (the first argument) at which the memory region ends.
----------------
lebedev.ri wrote:
> courbet wrote:
> > Do we want to specify that `end_offset` > `begin_offset` ? 
> `end_offset` can not be required to be bigger than `begin_offset`.
> E.g. consider the following 32-byte region: `[%ptr - 32, %ptr + 0]`,
> where `%ptr` is the `end` pointer.
> 
> Likewise, i don't think we can specify that
> the total region size is non-zero,
> because then we can't declare empty memory regions,
> where there only is a `end` pointer.
> 
> What i think is something that still needs to be better clarified,
> is whether the `begin_offset` should specify the
> offset from the beginning of the memory region to the pointer (i.e. be non-negative (`begin_offset s>= 0`)),
> or the offset from the pointer to the beginning of the memory region (i.e. be non-positive (`begin_offset s<= 0`)),
> 
> I guess, given that `end_offset` specifies the offset from the pointer
> to the `end` of the region, we want `begin_offset` to be symmetrical,
> and specify the offset from the pointer to the beginning of the memory region
> (i.e. be non-positive (`begin_offset s<= 0`)).
> 
> `end_offset` can not be required to be bigger than `begin_offset`.
> E.g. consider the following 32-byte region: `[%ptr - 32, %ptr + 0]`,
> where `%ptr` is the `end` pointer.

In that base, `begin_offset` is `-32` and `end_offset` is `0`, right ? So we still have `begin_offset <= end_offset`.

> Likewise, i don't think we can specify that
> the total region size is non-zero,
> because then we can't declare empty memory regions,
> where there only is a `end` pointer.

Yes you're right, obviously for the case of `int a[0]`. BTW there is an inconsistency between GNU C and C99 on this for flexible array members: in the former case we should not emit an annotation for this while we should for the latter.

> 
> What i think is something that still needs to be better clarified,
> is whether the `begin_offset` should specify the
> offset from the beginning of the memory region to the pointer (i.e. be non-negative (`begin_offset s>= 0`)),
> or the offset from the pointer to the beginning of the memory region (i.e. be non-positive (`begin_offset s<= 0`)),

My vote goes to `begin_offset >= 0` => memory region begins after the pointer.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115274



More information about the llvm-commits mailing list