[cfe-dev] cfe-dev Digest, Vol 139, Issue 16

Jon Chesterfield via cfe-dev cfe-dev at lists.llvm.org
Sat Jan 5 02:01:00 PST 2019

 Hi JF,

A few options:
> 1. Make them a builtin, have libc implementations forward to the builtin.
> 2. Teach clang / LLVM about these function’s semantics (i.e. if conditions
> met, same as memset).
> I think 1. is the best approach.

Could you expand on why 1 looks better than 2?

There's a lot of code that can be handled via clang builtin or via pattern
matching IR pass. All of libm for example. Some functions have both styles,
some even get converted from clang builtin to libm call to llvm intrinsic.

I'm in favour of recognising function calls and translating them to IR
intrinsics. This simplifies testing (via opt). It moves an optimisation out
of clang and into an IR pass which feels right. It also means &sin works,
though I know this to be forbidden.

As such I'm interested in your preference for doing this in clang, and
whether it generalises to other magic library functions.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190105/ce787c37/attachment.html>

More information about the cfe-dev mailing list