[PATCH] D39204: [CodeGen] __builtin_sqrt should map to the compiler's intrinsic sqrt function

Sanjay Patel via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 30 15:37:38 PDT 2017


spatel updated this revision to Diff 120902.
spatel added a comment.

Patch updated:
As suggested, I've morphed this patch to just handle sqrt libcalls based on the updated LLVM intrinsic definition.

I was going to include the builtins too, but that exposes another bug (marked here with FIXME) - the builtins are all defined 'const'. Therefore, they can never set errno (unless I'm still misunderstanding). So I think we are wrongly currently turning those into libcalls marked 'readnone'.

We could wrongly turn those into intrinsics in this patch if that seems better? :)

This does make me curious about the use-case of libm-equivalent builtins. If they are exactly identical to libm (including errno behavior), then why are they needed in the first place?


https://reviews.llvm.org/D39204

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/2005-07-20-SqrtNoErrno.c
  test/CodeGen/builtin-sqrt.c
  test/CodeGen/libcalls.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39204.120902.patch
Type: text/x-patch
Size: 6369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171030/7428f450/attachment.bin>


More information about the cfe-commits mailing list