[PATCH] D128907: [Clang] Disable noundef attribute for languages which allow uninitialized function arguments

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 14 08:16:16 PDT 2022


arsenm added a comment.

In D128907#3652140 <https://reviews.llvm.org/D128907#3652140>, @jdoerfert wrote:

> In D128907#3652077 <https://reviews.llvm.org/D128907#3652077>, @arsenm wrote:
>
>> In D128907#3650750 <https://reviews.llvm.org/D128907#3650750>, @jdoerfert wrote:
>>
>>> That said, I doubt this is even what we want. Throwing away the benefits of the noundef for one special case. IIRC, I mentioned alternatives in the other discussion already,... not that I have a link handy.
>>
>> I've spent a while thinking about this and don't see a better option. It's one special case, but since that special case can be called from arbitrary user code, I don't see how we can preserve noundef. We can't specially treat the handful of special intrinsics/operands for this, since we would transitively need to apply this to any user code which calls those functions
>
> I guess, that is the actual question here: Does CUDA/HIP overwrite the semantics of the base language entirely or make exceptions for the intrinsics they added.
> From what I can tell, CUDA/HIP did the latter. I am not sure how much their standards (if any) mention this.

As far as I can tell there's no explicit mention of this. However, there is apparently code in the wild where people are relying on this behavior. It seems almost reasonable, but I do wish this were defined.

> OpenMP offloading, for example, does not overwrite the base language (C/C++). For OpenMP we would want to make the intrinsics special but that's it. We would even be fine without any special handling  as the only uses are in our runtime (or other clang shipped code).
>
> If the HIP/CUDA people think we should give up on noundef arguments completely, let's do it by language rather than some implicit property (convergent). OpenCL & SYCL people should also comment. (ping @tra, @RaviNarayanaswamy, @bader, @Anastasia)

I do think we could go backwards and infer noundef like any other attribute, and take care to avoid inferring it in the presence of these intrinsics. I thought it was weird clang was adding these upfront in the first place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128907



More information about the llvm-commits mailing list