[flang-commits] [PATCH] D135853: [flang] Rename hypotf on MSVC platforms

Diana Picus via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Oct 13 00:28:33 PDT 2022


rovka created this revision.
rovka added reviewers: jeanPerier, vzakhari, DavidTruby, MatsPetersson, Meinersbur, mehdi_amini.
rovka added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
rovka requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

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
lowering.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135853

Files:
  flang/lib/Optimizer/CodeGen/CodeGen.cpp
  flang/test/Fir/rename-msvc-libm.fir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135853.467376.patch
Type: text/x-patch
Size: 3421 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221013/76b4a34e/attachment-0001.bin>


More information about the flang-commits mailing list