summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/builtins.c
Commit message (Collapse)AuthorAgeFilesLines
* Add __warn_memset_zero_len builtin as a workaround for glibc issueserge-sans-paille2020-01-171-0/+7
| | | | | | | | | Glibc issue: https://sourceware.org/bugzilla/show_bug.cgi?id=25399 The fix consist in considering the missing function as a builtin lowered to a nop. Differential Revision: https://reviews.llvm.org/D72869 (cherry picked from commit d293417931d3a9d46799b42795988ca3b5cfd766)
* Remove implicit conversion that promotes half to other larger precision ↵Jim Lin2019-12-101-1/+25
| | | | | | | | | | | | | | | | | | | | types for fp classification builtins Summary: It shouldn't promote half to double or any larger precision types for fp classification builtins. Because fp classification builtins would get incorrect result with promoted argument. For example, __builtin_isnormal with a subnormal half value should return false, but it is not. That the subnormal half value is promoted to a normal double value. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71049
* [clang] Handle lrint/llrint builtinsAdhemerval Zanella2019-05-281-0/+9
| | | | | | | | | | | | As for other floating-point rounding builtins that can be optimized when build with -fno-math-errno, this patch adds support for lrint and llrint. It currently only optimize for AArch64 backend. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D62019 llvm-svn: 361878
* [clang] Handle lround/llround builtinsAdhemerval Zanella2019-05-161-0/+10
| | | | | | | | | | | | As for other floating-point rounding builtins that can be optimized when build with -fno-math-errno, this patch adds support for lround and llround. It currently only optimize for AArch64 backend. Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D61392 llvm-svn: 360896
* [opaque pointer types] Cleanup CGBuilder's Create*GEP.James Y Knight2019-02-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Some of these functions take some extraneous arguments, e.g. EltSize, Offset, which are computable from the Type and DataLayout. Add some asserts to ensure that the computed values are consistent with the passed-in values, in preparation for eliminating the extraneous arguments. This also asserts that the Type is an Array for the calls named "Array" and a Struct for the calls named "Struct". Then, correct a couple of errors: 1. Using CreateStructGEP on an array type. (this causes the majority of the test differences, as struct GEPs are created with i32 indices, while array GEPs are created with i64 indices) 2. Passing the wrong Offset to CreateStructGEP in TargetInfo.cpp on x86-64 NACL (which uses 32-bit pointers). Differential Revision: https://reviews.llvm.org/D57766 llvm-svn: 353529
* CodeGen: Cast llvm.flt.rounds result to match __builtin_flt_roundsAnton Korobeynikov2019-01-171-0/+3
| | | | | | | | | | | | | llvm.flt.rounds returns an i32, but the builtin expects an integer. On targets where integers are not 32-bits clang tries to bitcast the result, causing an assertion failure. The patch enables newlib build for msp430. Patch by Edward Jones! Differential Revision: https://reviews.llvm.org/D24461 llvm-svn: 351449
* [Clang] Add __builtin_launderEric Fiselier2018-12-141-0/+11
| | | | | | | | | | | | | | | | | Summary: This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC. I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables. Reviewers: rnk, majnemer, rsmith Reviewed By: rsmith Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek Differential Revision: https://reviews.llvm.org/D40218 llvm-svn: 349195
* os_log: Allow specifying mask type in format string.Akira Hatanaka2018-11-061-0/+16
| | | | | | | | | | A mask type is a 1 to 8-byte string that follows the "mask." annotation in the format string. This enables obfuscating data in the event the provided privacy level isn't enabled. rdar://problem/36756282 llvm-svn: 346211
* os_log: Add a new privacy annotation "sensitive".Akira Hatanaka2018-11-061-0/+7
| | | | | | | | | | This is a stricter privacy annotation than "private", which will be used for data that shouldn’t be logged to disk. For backward compatibility, the "private" bit is set too. rdar://problem/36755912 llvm-svn: 346210
* os_log: Minor code cleanups. NFC.Akira Hatanaka2018-11-061-1/+4
| | | | | | Also, add a new test case and fix an incorrect comment. llvm-svn: 346209
* Reapply Logging: make os_log buffer size an integer constant expression.Tim Northover2018-11-021-5/+8
| | | | | | | | | | | | The size of an os_log buffer is known at any stage of compilation, so making it a constant expression means that the common idiom of declaring a buffer for it won't result in a VLA. That allows the compiler to skip saving and restoring the stack pointer around such buffers. This also moves the OSLog and other FormatString helpers from libclangAnalysis to libclangAST to avoid a circular dependency. llvm-svn: 345971
* Revert "Reapply Logging: make os_log buffer size an integer constant ↵Tim Northover2018-11-011-8/+5
| | | | | | | | expression." Still more dependency hell. llvm-svn: 345871
* Reapply Logging: make os_log buffer size an integer constant expression.Tim Northover2018-11-011-5/+8
| | | | | | | | | | | | The size of an os_log buffer is known at any stage of compilation, so making it a constant expression means that the common idiom of declaring a buffer for it won't result in a VLA. That allows the compiler to skip saving and restoring the stack pointer around such buffers. This also moves the OSLog helpers from libclangAnalysis to libclangAST to avoid a circular dependency. llvm-svn: 345866
* Revert "Logging: make os_log buffer size an integer constant expression.Tim Northover2018-11-011-8/+5
| | | | | | | | This also reverts a couple of follow-up commits trying to fix the dependency issues. Latest revision added a cyclic dependency that can't just be patched up in 5 minutes. llvm-svn: 345846
* Logging: make os_log buffer size an integer constant expression.Tim Northover2018-11-011-5/+8
| | | | | | | | | The size of an os_log buffer is known at any stage of compilation, so making it a constant expression means that the common idiom of declaring a buffer for it won't result in a VLA. That allows the compiler to skip saving and restoring the stack pointer around such buffers. llvm-svn: 345828
* os_log: When there are multiple privacy annotations in the formatAkira Hatanaka2018-07-111-2/+2
| | | | | | | | | | | string, choose the strictest one instead of the last. Also fix an undefined behavior. Move the pointer update to a later point to avoid adding StringRef::npos to the pointer. rdar://problem/40706280 llvm-svn: 336863
* Fix parsing of privacy annotations in os_log format strings.Akira Hatanaka2018-07-101-1/+23
| | | | | | | | | | Privacy annotations shouldn't have to appear in the first comma-delimited string in order to be recognized. Also, they should be ignored if they are preceded or followed by non-whitespace characters. rdar://problem/40706280 llvm-svn: 336629
* [CodeGen] convert math libcalls/builtins to equivalent LLVM intrinsicsSanjay Patel2017-12-011-3/+3
| | | | | | | | | | | | | | | | There are 20 LLVM math intrinsics that correspond to mathlib calls according to the LangRef: http://llvm.org/docs/LangRef.html#standard-c-library-intrinsics We were only converting 3 mathlib calls (sqrt, fma, pow) and 12 builtin calls (ceil, copysign, fabs, floor, fma, fmax, fmin, nearbyint, pow, rint, round, trunc) to their intrinsic-equivalents. This patch pulls the transforms together and handles all 20 cases. The switch is guarded by a check for const-ness to make sure we're not doing the transform if errno could possibly be set by the libcall or builtin. Differential Revision: https://reviews.llvm.org/D40044 llvm-svn: 319593
* Fix a bug with the use of __builtin_bzero in a conditional expression.John McCall2017-11-091-0/+13
| | | | | | Patch by Bharathi Seshadri! llvm-svn: 317776
* [CodeGen] add tests for __builtin_sqrt*; NFCSanjay Patel2017-10-201-0/+9
| | | | | | | I don't know if this is correct, but this is what we currently do. More discussion in PR27108 and PR27435 and D27618. llvm-svn: 316250
* [CodeGen] Emit a helper function for __builtin_os_log_format to reduceAkira Hatanaka2017-10-061-179/+335
| | | | | | | | | | | | | | | | | | | | | | | | | | | | code size. Currently clang expands a call to __builtin_os_log_format into a long sequence of instructions at the call site, causing code size to increase in some cases. This commit attempts to reduce code size by emitting a helper function that can be shared by calls to __builtin_os_log_format with similar formats and arguments. The helper function has linkonce_odr linkage to enable the linker to merge identical functions across translation units. Attribute 'noinline' is attached to the helper function at -Oz so that the inliner doesn't inline functions that can potentially be merged. This commit also fixes a bug where the generated IR writes past the end of the buffer when "%m" is the last specifier appearing in the format string passed to __builtin_os_log_format. Original patch by Duncan Exon Smith. rdar://problem/34065973 rdar://problem/34196543 Differential Revision: https://reviews.llvm.org/D38606 llvm-svn: 315045
* Fix printf specifier handling: invalid specifier should not be marked as ↵Mehdi Amini2016-12-151-0/+28
| | | | | | | | | | | | "consuming data arguments" Reviewers: rsmith, bruno, dexonsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27796 llvm-svn: 289850
* Revert "Fix printf specifier handling: invalid specifier should not be ↵Mehdi Amini2016-12-151-28/+0
| | | | | | | | marked as "consuming data arguments"" This reverts commit r289762, wasn't ready to be pushed, it broke the printf tests. llvm-svn: 289763
* Fix printf specifier handling: invalid specifier should not be marked as ↵Mehdi Amini2016-12-151-0/+28
| | | | | | "consuming data arguments" llvm-svn: 289762
* Fix os_log formating with arbitrary precision and field widthMehdi Amini2016-12-151-0/+49
| | | | llvm-svn: 289761
* Fix handling of %% format specifier in os_log builtins.Mehdi Amini2016-10-251-8/+19
| | | | | | | Returning `false` was stopping the parsing of further arguments, which wasn't intended. llvm-svn: 285047
* test/CodeGen/builtins.c: reinstate #ifdef __x86_64__ around __builtin_longjmpMehdi Amini2016-10-241-0/+5
| | | | | | Unadvertently removed in r285019 llvm-svn: 285041
* Fix test on non-X86 platformsMehdi Amini2016-10-241-0/+5
| | | | | | | This is a fixup for r285019, adding an `#ifdef __x86_64__` since the os_log builtin is platform specific. llvm-svn: 285027
* Add support for __builtin_os_log_format[_buffer_size]Mehdi Amini2016-10-241-3/+138
| | | | | | | | | | | | | | | | | This reverts commit r285007 and reapply r284990, with a fix for the opencl test that I broke. Original commit message follows: These new builtins support a mechanism for logging OS events, using a printf-like format string to specify the layout of data in a buffer. The _buffer_size version of the builtin can be used to determine the size of the buffer to allocate to hold the data, and then __builtin_os_log_format can write data into that buffer. This implements format checking to report mismatches between the format string and the data arguments. Most of this code was written by Chris Willmore. Differential Revision: https://reviews.llvm.org/D25888 llvm-svn: 285019
* Revert "Add support for __builtin_os_log_format[_buffer_size]"Mehdi Amini2016-10-241-138/+3
| | | | | | This reverts commit r284990, two opencl test are broken llvm-svn: 285007
* Add support for __builtin_os_log_format[_buffer_size]Mehdi Amini2016-10-241-3/+138
| | | | | | | | | | | | | | These new builtins support a mechanism for logging OS events, using a printf-like format string to specify the layout of data in a buffer. The _buffer_size version of the builtin can be used to determine the size of the buffer to allocate to hold the data, and then __builtin_os_log_format can write data into that buffer. This implements format checking to report mismatches between the format string and the data arguments. Most of this code was written by Chris Willmore. Differential Revision: https://reviews.llvm.org/D25888 llvm-svn: 284990
* Convert finite to builtinDehao Chen2016-09-141-0/+4
| | | | | | | | | | | | Summary: This patch converts finite/__finite to builtin functions so that it will be inlined by compiler. Reviewers: hfinkel, davidxl, efriedma Subscribers: efriedma, llvm-commits Differential Revision: https://reviews.llvm.org/D24483 llvm-svn: 281509
* Emit more intrinsics for builtin functionsMatt Arsenault2016-07-011-0/+92
| | | | | | | | | | | | This is important for building libclc. Since r273039 tests are failing due to now emitting calls to these functions instead of emitting the DAG node. The libm function names are implemented for OpenCL, and should call the locally defined versions, so -fno-builtin is used. The IR Some functions use the __builtins and expect the intrinsics to be emitted. Without this we end up with nobuiltin calls to intrinsics or to unsupported library calls. llvm-svn: 274370
* make __builtin_isfinite more efficient (PR27145)Sanjay Patel2016-04-071-3/+1
| | | | | | | | | | | | | | isinf (is infinite) and isfinite should be implemented with the same function except we change the comparison operator. See PR27145 for more details: https://llvm.org/bugs/show_bug.cgi?id=27145 Ref: forked off of the discussion in D18513. Differential Revision: http://reviews.llvm.org/D18648 llvm-svn: 265675
* Add missing __builtin_bitreverse8Matt Arsenault2016-03-231-0/+2
| | | | | | Also add documentation for bitreverse builtins llvm-svn: 264203
* Add __builtin_canonicalizeMatt Arsenault2016-02-271-0/+7
| | | | llvm-svn: 262122
* Add builtins for bitreverse intrinsicMatt Arsenault2016-02-031-0/+8
| | | | | | | Follow the naming convention that bswap uses since it's a similar sort of operation. llvm-svn: 259671
* [Modules] Implement __builtin_isinf_sign in Clang.Chandler Carruth2015-03-191-4/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Somehow, we never managed to implement this fully. We could constant fold it like crazy, including constant folding complex arguments, etc. But if you actually needed to generate code for it, error. I've implemented it using the somewhat obvious lowering. Happy for suggestions on a more clever way to lower this. Now, what you might ask does this have to do with modules? Fun story. So it turns out that libstdc++ actually uses __builtin_isinf_sign to implement std::isinf when in C++98 mode, but only inside of a template. So if we're lucky, and we never instantiate that, everything is good. But once we try to instantiate that template function, we need this builtin. All of my customers at least are using C++11 and so they never hit this code path. But what does that have to do with modules? Fun story. So it turns out that with modules we actually observe a bunch of bugs in libstdc++ where their <cmath> header clobbers things exposed by <math.h>. To fix these, we have to provide global function definitions to replace the macros that C99 would have used. And it turns out that ::isinf needs to be implemented using the exact semantics used by the C++98 variant of std::isinf. And so I started to fix this bug in libstdc++ and ceased to be able to compile libstdc++ with Clang. The yaks are legion. llvm-svn: 232778
* Fix test/CodeGen/builtins.c for platforms that don't lower sjljReid Kleckner2015-03-041-0/+3
| | | | | | | | Opt in Win64 to supporting sjlj lowering. We have the backend lowering, so I think this was just an oversight because WinX86_64TargetCodeGenInfo doesn't inherit from X86_64TargetCodeGenInfo. llvm-svn: 231280
* Lower __builtin_fabs* to @llvm.fabs.*Reid Kleckner2014-11-031-0/+7
| | | | | | | | | mingw64's headers implement fabs by calling __builtin_fabs, so using the library call results in an infinite loop. If the backend legalizes @llvm.fabs as a call to fabs later, things should work out, as the crt provides a definition. llvm-svn: 221206
* CGBuiltin: Use frem instruction rather than libcall to implement fmodJan Vesely2014-09-261-0/+16
| | | | | | | | AFAICT the semantics of frem match libm's fmod. Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu> Reviewed-by: Tom Stellard <tom@stellard.net> llvm-svn: 218488
* CGBuiltin: Use @llvm.fabs rather than fabs libcall when emitting builtinsTom Stellard2014-09-031-5/+5
| | | | | | | | | | | Using the intrinsic allows the SelectionDAGBuilder to turn this call into the FABS Node and also the intrinsic is something the vectorizer knows how to vectorize. This patch also sets the readnone attribute on this call, which should enable additional optmizations. llvm-svn: 217042
* CHECK-LABEL-ify some code gen tests to improve diagnostic experience when ↵Stephen Lin2013-08-151-4/+4
| | | | | | tests fail. llvm-svn: 188447
* Expose __builtin_bswap16.Benjamin Kramer2012-10-061-0/+1
| | | | | | | GCC has always supported this on PowerPC and 4.8 supports it on all platforms, so it's a good idea to expose it in clang too. LLVM supports this on all targets. llvm-svn: 165362
* Add __builtin_readcyclecounter() to produce the @llvm.readcyclecounter() ↵Hal Finkel2012-08-051-0/+6
| | | | | | intrinsic. llvm-svn: 161310
* fix a bunch of comment typos found by codespell. Patch byChris Lattner2011-04-151-1/+1
| | | | | | Luis Felipe Strano Moraes! llvm-svn: 129559
* Enable basic testing of __builtin_fpclassify.Benjamin Kramer2010-06-141-2/+3
| | | | llvm-svn: 105937
* Enable the implementation of __builtin_setjmp and __builtin_longjmp. Not allJohn McCall2010-05-271-0/+7
| | | | | | LLVM backends support these yet. llvm-svn: 104867
* Implement codegen for __builtin_isnormal.Benjamin Kramer2010-05-191-0/+8
| | | | llvm-svn: 104118
* implement codegen support for __builtin_isfinite, part of PR6083Chris Lattner2010-05-061-2/+8
| | | | llvm-svn: 103168
OpenPOWER on IntegriCloud