[PATCH] D31806: [SimplifyLibCalls] Fix infinite loop with fast-math optimization.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 12 10:55:41 PDT 2017


efriedma added a comment.

On 32-bit Windows, the compiler is aware that the standard library doesn't have an expf implementation, and therefore doesn't treat it as a builtin function.



================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:945
+      if (FT->getReturnType()->isFloatTy() && (FT->getNumParams() == 1) &&
+          FT->getParamType(0)->isFloatTy())
+        return nullptr;
----------------
andrewng wrote:
> efriedma wrote:
> > The FunctionType check doesn't seem necessary here.
> Wouldn't this be more correct? There's always the remote possibility that someone might have a function named expf with a different signature that calls exp.
In that case, we're not only calling the wrong expf, we're calling it with the wrong signature, so we still would want to suppress the transform.


================
Comment at: test/Transforms/Util/libcalls-fast-math-inf-loop.ll:1
+; RUN: opt -S -O2 -o - %s | FileCheck %s
+
----------------
andrewng wrote:
> efriedma wrote:
> > Please don't use -O2 in tests... just test the specific pass you care about (in this case, instcombine).
> Yes, I wasn't too happy with this either. However, just the instcombine wasn't enough to cause the infinite loop. I will try to figure out what else is needed to trigger this behaviour.
You can use `opt -print-after-all` to grab the IR before the bad transform.


https://reviews.llvm.org/D31806





More information about the llvm-commits mailing list