[all-commits] [llvm/llvm-project] 36799d: [flang] Rename hypotf on MSVC platforms

Diana via All-commits all-commits at lists.llvm.org
Fri Oct 21 02:10:09 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 36799dfd519ccaa1170efe36d907c0b513c50203
  Author: Diana Picus <diana.picus at linaro.org>
  Date:   2022-10-21 (Fri, 21 Oct 2022)

  Changed paths:
    M flang/lib/Optimizer/CodeGen/CodeGen.cpp
    A flang/test/Fir/rename-msvc-libm.fir

  Log Message:
  [flang] Rename hypotf on MSVC platforms

The single precision `hypot` intrinsic is lowered to a call to the libm
`hypotf` function.  However, the MSVC runtime lacks a hypotf function
and instead uses `_hypotf` (*). This patch tries to find and rewrite
calls to `hypotf` if we're on a MSVC platform.

Calls to libm functions can be introduced even after lowering (**).
Therefore, we try to do the rewriting at the very end of FIR to LLVM

Fixes https://github.com/llvm/llvm-project/issues/57563

(*) More specifically, MSVC's headers define hypotf as an inline
function that just calls _hypotf. This works fine for clang, since it
will include those headers, but flang only links with the CRT so we
don't get a free ride.

(**) https://github.com/llvm/llvm-project/blob/56f94ede2af9a327e59fe84dbf8cbbb7bb1dfa79/flang/lib/Optimizer/CodeGen/CodeGen.cpp#L3391

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

More information about the All-commits mailing list