OSDN Git Service

Add a emitUnaryFloatFnCall version that fetches the function name from TLI
authorMikael Holmen <mikael.holmen@ericsson.com>
Thu, 18 Oct 2018 06:27:53 +0000 (06:27 +0000)
committerMikael Holmen <mikael.holmen@ericsson.com>
Thu, 18 Oct 2018 06:27:53 +0000 (06:27 +0000)
commit577c9cec20a08d178592dad641b5c4753e3bbf88
tree8cf37e491e6182a35e3b2755a25ee21454596ce2
parente97176ffbab1ac950d9ad57cdafc38a0e069ff11
Add a emitUnaryFloatFnCall version that fetches the function name from TLI

Summary:
In several places in the code we use the following pattern:

  if (hasUnaryFloatFn(&TLI, Ty, LibFunc_tan, LibFunc_tanf, LibFunc_tanl)) {
    [...]
    Value *Res = emitUnaryFloatFnCall(X, TLI.getName(LibFunc_tan), B, Attrs);
    [...]
  }

In short, we check if there is a lib-function for a certain type, and then
we _always_ fetch the name of the "double" version of the lib function and
construct a call to the appropriate function, that we just checked exists,
using that "double" name as a basis.

This is of course a problem in cases where the target doesn't support the
"double" version, but e.g. only the "float" version.

In that case TLI.getName(LibFunc_tan) returns "", and
emitUnaryFloatFnCall happily appends an "f" to "", and we erroneously end
up with a call to a function called "f".

To solve this, the above pattern is changed to

  if (hasUnaryFloatFn(&TLI, Ty, LibFunc_tan, LibFunc_tanf, LibFunc_tanl)) {
    [...]
    Value *Res = emitUnaryFloatFnCall(X, &TLI, LibFunc_tan, LibFunc_tanf,
                                      LibFunc_tanl, B, Attrs);
    [...]
  }

I.e instead of first fetching the name of the "double" version and then
letting emitUnaryFloatFnCall() add the final "f" or "l", we let
emitUnaryFloatFnCall() fetch the right name from TLI.

Reviewers: eli.friedman, efriedma

Reviewed By: efriedma

Subscribers: efriedma, bjope, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344725 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Transforms/Utils/BuildLibCalls.h
lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
lib/Transforms/Utils/BuildLibCalls.cpp
lib/Transforms/Utils/SimplifyLibCalls.cpp