[all-commits] [llvm/llvm-project] ef110a: [Builtins] Do not claim most libfuncs are readnone...

Florian Hahn via All-commits all-commits at lists.llvm.org
Thu Aug 11 04:29:33 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ef110a491f702e84d3f97e7cde6dacea99fd238d
      https://github.com/llvm/llvm-project/commit/ef110a491f702e84d3f97e7cde6dacea99fd238d
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2022-08-11 (Thu, 11 Aug 2022)

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

  Log Message:
  -----------
  [Builtins] Do not claim most libfuncs are readnone with trapping math.

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.

Reviewed By: john.brawn

Differential Revision: https://reviews.llvm.org/D129231




More information about the All-commits mailing list