[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
Wed Jul 6 15:05:59 PDT 2022


fhahn created this revision.
fhahn added reviewers: kpn, efriedma, scanon, john.brawn, sepavloff.
Herald added a project: All.
fhahn requested review of this revision.
Herald added a project: clang.

At the moment, Clang only considers errno when deciding if a builtin
is const. This ignores the fact that some library functions may raise
floating point exceptions, which may modify global state, e.g. when
updating FP status registers.

To model the fact that some library functions/builtins may raise
floating point exceptions, this patch adds a new 'g' modifier for
builtins. If a builtin is marked with 'g', it cannot be considered
const, unless FP exceptions are ignored.

So far I've not added CHECK lines for all calls in math-libcalls.c. I'll
do that once we agree on the overall direction.

A consequence seems to be that we fail to select some of the constrained
math builtins now, but I am not entirely sure what's going on there.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129231

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129231.442696.patch
Type: text/x-patch
Size: 29437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220706/c94d04a8/attachment-0001.bin>


More information about the cfe-commits mailing list