[cfe-dev] Feature Request: __builtin_undefined()

Tim Northover via cfe-dev cfe-dev at lists.llvm.org
Sat Oct 7 12:16:54 PDT 2017


On 7 October 2017 at 10:10, Ryan Nicholl via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> I like to distinguish my proposed __builtin_undefined() from
> __builtin_unreachable() in that __builtin_unreachable() should really be
> unreachable. (Even if the user e.g. uses an invalid input index?) (i.e., it
> should indicate a bug in the code that uses __builtin_unreachable() rather
> than in the calling code)

I don't think I see the distinction at all, I'm afraid:

  + UBSan already instruments calls to __builtin_unreachable.
  + Reaching it already counts as UB as far as LLVM is concerned.
  + Optimizations already exploit it.
  + The caller/callee mistake distinction doesn't really exist once
inlining happens.

Do you have any concrete examples where some part of LLVM
could/would/should treat them differently? Would something permitted
of forbidden by this new intrinsic? I can't even really tell which way
it'd go.

Cheers.

Tim.



More information about the cfe-dev mailing list