[PATCH] D63294: [Analysis] enhance FP library function prototype checking to match types with name suffix

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 19 12:50:51 PDT 2019


spatel added a comment.

In D63294#1550878 <https://reviews.llvm.org/D63294#1550878>, @spatel wrote:

> In D63294#1550775 <https://reviews.llvm.org/D63294#1550775>, @efriedma wrote:
>
> > Not sure what you're talking about with clang; it does the right thing, as far as I can tell.
>
>
> When compiling for AVR, clang will turn the libcall that uses doubles in C source into:
>
>   %call = call addrspace(1) float @sqrt(float 0.000000e+00) #2
>   
>
> Should clang translate that call into "sqrtf" to be more accurate? Similarly, if the source was written with "sqrtl" and "long double", we'd get this IR out of clang:
>
>   %call = call addrspace(1) float @sqrtl(float 0.000000e+00) #2


And I should've mentioned this in the earlier comment, both of those calls can be translated to the LLVM sqrt intrinsic (if we have no-errno) because checking for builtins appears to be done solely by name:

  bool Builtin::Context::isBuiltinFunc(const char *Name) {
    StringRef FuncName(Name);
    for (unsigned i = Builtin::NotBuiltin + 1; i != Builtin::FirstTSBuiltin; ++i)
      if (FuncName.equals(BuiltinInfo[i].Name))
        return strchr(BuiltinInfo[i].Attributes, 'f') != nullptr;
  
    return false;
  }


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

https://reviews.llvm.org/D63294





More information about the llvm-commits mailing list