[PATCH] D90529: Allow nonnull/align attribute to accept poison

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 1 05:50:18 PST 2021


aqjune added a comment.

In D90529#2449558 <https://reviews.llvm.org/D90529#2449558>, @aqjune wrote:

> In D90529#2449524 <https://reviews.llvm.org/D90529#2449524>, @jdoerfert wrote:
>
>> In D90529#2449341 <https://reviews.llvm.org/D90529#2449341>, @aqjune wrote:
>>
>>> Should we have clarification about the semantics of align/nonnull bundle for the assume intrinsic?
>>
>> Probably true, good catch. Why not make it the same as the attribute? So,
>>
>>   ; A correct transformation
>>   call f(nonnull %p, nonnull noundef %q)
>>   ->
>>   llvm.assume [ "nonnull"(%p), "nonnull"(%q), "noundef"(%q)]
>>   ; where a `null` value for %p can be assumed to be a poison value and
>>   ; a `null` value for %q can be assumed to cause UB because `noundef` of
>>   ; poison is UB.
>
> +1, I'll make a separate patch for this.

While writing the LangRef patch for the semantic changes in nonnull & align attributes in assume operand bundle, I found one interesting case. :)

Creating assume from these two calls yields the same result:

  call void @hi1(i8* nonnull %val, i8* noundef %val)
  call void @hi2(i8* nonnull noundef %val)

They both generate:

  call void @llvm.assume(true)["nonnull"(i8* %val), "noundef"(i8* %val)]

A question is whether this assume is UB if, say, %val is `inttoptr(1)`.
Creating this assume from `call void @hi2(%val)` is okay because `call void @hi2(%val)` is already UB.
But, creating the assume from `call void @hi1(%val, %val)` isn't okay! `%val` is non-null and noundef, so the call is fine.

To distinguish these two, should we simply use UB semantics for nonnull attribute in assume operand bundle?
Then, we don't need to change anything about nonnull from LangRef: the current text is defining it as UB (https://llvm.org/docs/LangRef.html#assume-operand-bundles ).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90529



More information about the llvm-commits mailing list