[PATCH] D129231: [Builtins] Do not claim all libfuncs are readnone with trapping math.

Florian Hahn via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 29 07:40:20 PDT 2022


fhahn updated this revision to Diff 448628.
fhahn added a comment.



In D129231#3638946 <https://reviews.llvm.org/D129231#3638946>, @john.brawn wrote:

> Looking at the descriptions of maths functions in C99 (and I expect C11 will be the same) it looks like there are three kinds:
>
> - Those that can report error by errno and floating-point exeption, and may also raise the inexact exception
> - Those that don't set errno, but may raise the inexact exception
> - Those that neither set errno or raise an exception
>
> Looking at this patch and the attributes of the various function intrinsics it looks like you have:
>
> - Marked "e": Can set errno, can't raise exception
> - Marked "eg": Can set errno and raise exception
> - Marked "cg": Can't set errno, can raise an exception
> - Marked "c": Can't set errno or raise an exception
>
> Given that the functions that set errno also raise exceptions I think it would make sense to have the "e" attribute cover both errno and exceptions, and have "g" just for those that can only raise exceptions. Also "cg" looks like it's probably wrong and should be "g" (given that "c" means "always const" and "g" means "const only when we don't have exceptions", and that's also how "e" is used in that we don't have functions with "cg").

Thanks you very much for taking a look! I updated the patch to redefine "e" to mean const if no errno and no exceptions. Now the only markings are either "e" or "g". The functions originally marked "cg" were indeed a mistake.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129231

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/Builtins.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGen/math-libcalls.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129231.448628.patch
Type: text/x-patch
Size: 27527 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220729/2d7f50c0/attachment-0001.bin>


More information about the cfe-commits mailing list