[PATCH] D95122: [Libcalls, Attrs] Annotate libcalls with noundef

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 21 07:50:41 PST 2021


xbolva00 added a comment.

In D95122#2512575 <https://reviews.llvm.org/D95122#2512575>, @aqjune wrote:

> In D95122#2512404 <https://reviews.llvm.org/D95122#2512404>, @jdoerfert wrote:
>
>> LGTM. FWIW, `nonnull` should imply `noundef` because if it was `undef` we could pick `null`.
>
> I did not look into the changes in this patch yet,  but does it mean that from
>
>   f(i8* nonnull %p)
>
> it is allowed to attach noundef?
>
>   f(i8* nonnull noundef %p)
>
> I think this shouldn't be allowed, because the former one isn't UB when %p was null but the latter one raises UB.
>
> In D95122#2512515 <https://reviews.llvm.org/D95122#2512515>, @nikic wrote:
>
>> I think this goes against the rules established in D87994 <https://reviews.llvm.org/D87994>, which allows memory accesses based on partially undefined values. Now, I think the change in D87994 <https://reviews.llvm.org/D87994> was a very bad one and we should undo it, but until then I don't think we can annotate with noundef here.
>
> I remember that this was to allow free code motion of load/stores if the offset is within bounds.
> e.g
>
>   %p = alloca [8 x i32]
>   %q = gep %p, %i ; %i may be partially undef
>   load %q ; If 0 <= %i < 8, %q is dereferenceable even if %q is partially undefined

but we are talking about specific libcalls, so eg. strlen(p), where p is null, is UB.


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

https://reviews.llvm.org/D95122



More information about the llvm-commits mailing list