[PATCH] D46135: [Driver, CodeGen] add options to enable/disable an FP cast optimization

Sanjay Patel via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 26 10:44:56 PDT 2018


spatel created this revision.
spatel added reviewers: jgorbe, chandlerc, scanon, hans, echristo.
Herald added a subscriber: mcrosier.

As discussed in the post-commit thread for:
https://reviews.llvm.org/rL330437 ( http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20180423/545906.html )

We need a way to opt-out of a float-to-int-to-float cast optimization because too much existing code relies on the platform-specific undefined result of those casts when the float-to-int overflows.

I speculatively committed the LLVM changes associated with adding this function attribute, but I'll change the name/implementation if there's a better alternative:
https://reviews.llvm.org/rL330947
https://reviews.llvm.org/rL330950
https://reviews.llvm.org/rL330951

Also as suggested, I changed the LLVM doc to mention the specific sanitizer flag that catches this problem:
https://reviews.llvm.org/rL330958

I tested the end-to-end results on x86 and see the expected outcome: 'roundss' is no longer produced in place of cvttss2si + cvtsi2ss with default optimization.


https://reviews.llvm.org/D46135

Files:
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/no-junk-ftrunc.c
  test/Driver/fast-math.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46135.144153.patch
Type: text/x-patch
Size: 6434 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180426/fe2c4fe4/attachment-0001.bin>


More information about the cfe-commits mailing list