[PATCH] D142388: [clang] Add builtin_nondeterministic_value

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 15 09:39:50 PDT 2023


aaron.ballman added a comment.

In D142388#4415349 <https://reviews.llvm.org/D142388#4415349>, @rsmith wrote:

> I think `__builtin_any_value` works pretty well, and emphasizes that this can really return any value. I'd also be OK with `__builtin_convenient_value`, to emphasize that the compiler will pick something that's convenient for it, but I prefer `__builtin_any_value`.

I can get behind `__builtin_any_value` as the name.

@ManuelJBrito: would you be willing to make these modifications?



================
Comment at: clang/docs/LanguageExtensions.rst:3087
+
+``__builtin_nondeterministic_value`` returns a valid nondeterministic value of the same type as the provided argument.
+
----------------
rsmith wrote:
> xbolva00 wrote:
> > This text really sells this new builtin as a random value generator..
> How about something more like this:
> 
> > ``__builtin_any_value`` returns an arbitrary value of the same type as the provided argument.
> >
> > [...]
> >
> > **Description**:
> >
> > Each call to ``__builtin_any_value`` returns an arbitrary value of the type given by the argument. The returned value will be chosen in a way that is convenient for the compiler, and may for example be a value left behind in a register or on the stack from a previous operation, or a value that causes a later calculation to always produce the same result. This function will not necessarily return a meaningful value if there are bit-patterns for the given type that do not correspond to meaningful values.
> 
> (I really want this to also not say it will produce a "valid value", because the valid values for a type are not in general known to the frontend. For a pointer, for example, this can return literally any bit pattern, and most of those will not be valid in any meaningful sense.)
I like this new formulation -- it makes it more clear that you can get a trap representation for the value, for example.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142388



More information about the cfe-commits mailing list