summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/builtins-overflow.c
Commit message (Collapse)AuthorAgeFilesLines
* [CodeGen] Handle mixed-width ops in mixed-sign mul-with-overflow loweringVedant Kumar2018-12-181-0/+21
| | | | | | | | | | | | | | | | | | | | | | The special lowering for __builtin_mul_overflow introduced in r320902 fixed an ICE seen when passing mixed-sign operands to the builtin. This patch extends the special lowering to cover mixed-width, mixed-sign operands. In a few common scenarios, calls to muloti4 will no longer be emitted. This should address the latest comments in PR34920 and work around the link failure seen in: https://bugzilla.redhat.com/show_bug.cgi?id=1657544 Testing: - check-clang - A/B output comparison with: https://gist.github.com/vedantk/3eb9c88f82e5c32f2e590555b4af5081 Differential Revision: https://reviews.llvm.org/D55843 llvm-svn: 349542
* Bring r325915 back.Rafael Espindola2018-02-231-9/+9
| | | | | | | | | | | | | | | The tests that failed on a windows host have been fixed. Original message: Start setting dso_local for COFF. With this there are still some GVs where we don't set dso_local because setGVProperties is never called. I intend to fix that in followup commits. This is just the bare minimum to teach shouldAssumeDSOLocal what it should do for COFF. llvm-svn: 325940
* Revert "Start setting dso_local for COFF."Rafael Espindola2018-02-231-9/+9
| | | | | | | | This reverts commit r325915. It will take some time to fix the failures on a windows host. llvm-svn: 325929
* Start setting dso_local for COFF.Rafael Espindola2018-02-231-9/+9
| | | | | | | | | With this there are still some GVs where we don't set dso_local because setGVProperties is never called. I intend to fix that in followup commits. This is just the bare minimum to teach shouldAssumeDSOLocal what it should do for COFF. llvm-svn: 325915
* [CGBuiltin] Handle unsigned mul overflow properly (PR35750)Vedant Kumar2018-01-031-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | r320902 fixed the IRGen for some types of checked multiplications. It did not handle unsigned overflow correctly in the case where the signed operand is negative (PR35750). Eli pointed out that on overflow, the result must be equal to the unique value that is equivalent to the mathematically-correct result modulo two raised to the k power, where k is the number of bits in the result type. This patch fixes the specialized IRGen from r320902 accordingly. Testing: Apart from check-clang, I modified the test harness from r320902 to validate the results of all multiplications -- not just the ones which don't overflow: https://gist.github.com/vedantk/3eb9c88f82e5c32f2e590555b4af5081 llvm.org/PR35750, rdar://34963321 Differential Revision: https://reviews.llvm.org/D41717 llvm-svn: 321771
* [CodeGen] Specialize mixed-sign mul-with-overflow (fix PR34920)Vedant Kumar2017-12-161-0/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces a specialized way to lower overflow-checked multiplications with mixed-sign operands. This fixes link failures and ICEs on code like this: void mul(int64_t a, uint64_t b) { int64_t res; __builtin_mul_overflow(a, b, &res); } The generic checked-binop irgen would use a 65-bit multiplication intrinsic here, which requires runtime support for _muloti4 (128-bit multiplication), and therefore fails to link on i386. To get an ICE on x86_64, change the example to use __int128_t / __uint128_t. Adding runtime and backend support for 65-bit or 129-bit checked multiplication on all of our supported targets is infeasible. This patch solves the problem by using simpler, specialized irgen for the mixed-sign case. llvm.org/PR34920, rdar://34963321 Testing: Apart from check-clang, I compared the output from this fairly comprehensive test driver using unpatched & patched clangs: https://gist.github.com/vedantk/3eb9c88f82e5c32f2e590555b4af5081 Differential Revision: https://reviews.llvm.org/D41149 llvm-svn: 320902
* Add support for __builtin_{add,sub,mul}_overflow.John McCall2015-10-291-0/+165
| | | | | | Patch by David Grayson! llvm-svn: 251651
* Don't pass -O0 to clang_cc1, it is the default.Rafael Espindola2013-09-041-3/+3
| | | | llvm-svn: 189910
* [checked-arithmetic builtins] Added builtins to enable users to perform ↵Michael Gottesman2013-06-201-0/+175
checked-arithmetic in c. This will enable users in security critical applications to perform checked-arithmetic in a fast safe manner that is amenable to c. Tests/an update to Language Extensions is included as well. rdar://13421498. llvm-svn: 184497
OpenPOWER on IntegriCloud