PR c/59708
* builtin-attrs.def (ATTR_NOTHROW_TYPEGENERIC_LEAF): New attribute.
* builtins.c (fold_builtin_arith_overflow): New function.
(fold_builtin_3): Use it.
* builtins.def (BUILT_IN_ADD_OVERFLOW, BUILT_IN_SUB_OVERFLOW,
BUILT_IN_MUL_OVERFLOW, BUILT_IN_SADD_OVERFLOW, BUILT_IN_SADDL_OVERFLOW,
BUILT_IN_SADDLL_OVERFLOW, BUILT_IN_SSUB_OVERFLOW,
BUILT_IN_SSUBL_OVERFLOW, BUILT_IN_SSUBLL_OVERFLOW,
BUILT_IN_SMUL_OVERFLOW, BUILT_IN_SMULL_OVERFLOW,
BUILT_IN_SMULLL_OVERFLOW, BUILT_IN_UADDL_OVERFLOW,
BUILT_IN_UADDLL_OVERFLOW, BUILT_IN_USUB_OVERFLOW,
BUILT_IN_USUBL_OVERFLOW, BUILT_IN_USUBLL_OVERFLOW,
BUILT_IN_UMUL_OVERFLOW, BUILT_IN_UMULL_OVERFLOW,
BUILT_IN_UMULLL_OVERFLOW): New built-in functions.
* builtin-types.def (BT_PTR_UINT, BT_PTR_ULONG, BT_PTR_LONGLONG,
BT_FN_BOOL_INT_INT_INTPTR, BT_FN_BOOL_LONG_LONG_LONGPTR,
BT_FN_BOOL_LONGLONG_LONGLONG_LONGLONGPTR, BT_FN_BOOL_UINT_UINT_UINTPTR,
BT_FN_BOOL_ULONG_ULONG_ULONGPTR,
BT_FN_BOOL_ULONGLONG_ULONGLONG_ULONGLONGPTR, BT_FN_BOOL_VAR): New.
* expr.c (write_complex_part): Remove prototype, no longer static.
* expr.h (write_complex_part): New prototype.
* function.c (aggregate_value_p): For internal functions return 0.
* gimple-fold.c (arith_overflowed_p): New functions.
(gimple_fold_call): Fold {ADD,SUB,MUL}_OVERFLOW internal calls.
* gimple-fold.h (arith_overflowed_p): New prototype.
* tree-ssa-dce.c: Include tree-ssa-propagate.h and gimple-fold.h.
(find_non_realpart_uses, maybe_optimize_arith_overflow): New
functions.
(eliminate_unnecessary_stmts): Transform {ADD,SUB,MUL}_OVERFLOW
into COMPLEX_CST/COMPLEX_EXPR if IMAGPART_EXPR of the result is
never used.
* gimplify.c (gimplify_call_expr): Handle gimplification of
internal calls with lhs.
* internal-fn.c (get_range_pos_neg, get_min_precision,
expand_arith_overflow_result_store): New functions.
(ubsan_expand_si_overflow_addsub_check): Renamed to ...
(expand_addsub_overflow): ... this. Add LOC, LHS, ARG0, ARG1,
UNSR_P, UNS0_P, UNS1_P, IS_UBSAN arguments, remove STMT argument.
Handle ADD_OVERFLOW and SUB_OVERFLOW expansion.
(ubsan_expand_si_overflow_neg_check): Renamed to ...
(expand_neg_overflow): ... this. Add LOC, LHS, ARG1, IS_UBSAN
arguments, remove STMT argument. Handle SUB_OVERFLOW with
0 as first argument expansion.
(ubsan_expand_si_overflow_mul_check): Renamed to ...
(expand_mul_overflow): ... this. Add LOC, LHS, ARG0, ARG1,
UNSR_P, UNS0_P, UNS1_P, IS_UBSAN arguments, remove STMT argument.
Handle MUL_OVERFLOW expansion.
(expand_UBSAN_CHECK_ADD): Use expand_addsub_overflow, prepare
arguments for it.
(expand_UBSAN_CHECK_SUB): Use expand_addsub_overflow or
expand_neg_overflow, prepare arguments for it.
(expand_UBSAN_CHECK_MUL): Use expand_mul_overflow, prepare arguments
for it.
(expand_arith_overflow, expand_ADD_OVERFLOW, expand_SUB_OVERFLOW,
expand_MUL_OVERFLOW): New functions.
* internal-fn.def (ADD_OVERFLOW, SUB_OVERFLOW, MUL_OVERFLOW): New
internal functions.
* tree-vrp.c (check_for_binary_op_overflow): New function.
(extract_range_basic): Handle {REAL,IMAG}PART_EXPR if the operand
is SSA_NAME set by {ADD,SUB,MUL}_OVERFLOW internal functions.
(simplify_internal_call_using_ranges): Handle {ADD,SUB,MUL}_OVERFLOW
internal functions.
* optabs.def (umulv4_optab): New optab.
* config/i386/i386.md (umulv<mode>4, <u>mulvqi4): New define_expands.
(*umulv<mode>4, *<u>mulvqi4): New define_insns.
* doc/extend.texi (Integer Overflow Builtins): Document
__builtin_*_overflow.
c-family/
* c-common.c (check_builtin_function_arguments): Handle
BUILT_IN_{ADD,SUB,MUL}_OVERFLOW.
testsuite/
* c-c++-common/builtin-arith-overflow-1.c: New test.
* c-c++-common/torture/builtin-arith-overflow-10.c: New test.
* c-c++-common/torture/builtin-arith-overflow-11.c: New test.
* c-c++-common/torture/builtin-arith-overflow-12.c: New test.
* c-c++-common/torture/builtin-arith-overflow-12.h: New file.
* c-c++-common/torture/builtin-arith-overflow-13.c: New test.
* c-c++-common/torture/builtin-arith-overflow-14.c: New test.
* c-c++-common/torture/builtin-arith-overflow-15.c: New test.
* c-c++-common/torture/builtin-arith-overflow-16.c: New test.
* c-c++-common/torture/builtin-arith-overflow-17.c: New test.
* c-c++-common/torture/builtin-arith-overflow-18.c: New test.
* c-c++-common/torture/builtin-arith-overflow-1.c: New test.
* c-c++-common/torture/builtin-arith-overflow-1.h: New file.
* c-c++-common/torture/builtin-arith-overflow-2.c: New test.
* c-c++-common/torture/builtin-arith-overflow-3.c: New test.
* c-c++-common/torture/builtin-arith-overflow-4.c: New test.
* c-c++-common/torture/builtin-arith-overflow-5.c: New test.
* c-c++-common/torture/builtin-arith-overflow-6.c: New test.
* c-c++-common/torture/builtin-arith-overflow-7.c: New test.
* c-c++-common/torture/builtin-arith-overflow-8.c: New test.
* c-c++-common/torture/builtin-arith-overflow-9.c: New test.
* c-c++-common/torture/builtin-arith-overflow.h: New file.
* gcc.dg/builtin-arith-overflow-1.c: New test.
* gcc.dg/builtin-arith-overflow-2.c: New test.
From-SVN: r217415
| Name |
Last commit
|
Last update |
|---|---|---|
| .. | ||
| adxintrin.h | Loading commit data... | |
| ammintrin.h | Loading commit data... | |
| athlon.md | Loading commit data... | |
| atom.md | Loading commit data... | |
| att.h | Loading commit data... | |
| avx2intrin.h | Loading commit data... | |
| avx512bwintrin.h | Loading commit data... | |
| avx512cdintrin.h | Loading commit data... | |
| avx512dqintrin.h | Loading commit data... | |
| avx512erintrin.h | Loading commit data... | |
| avx512fintrin.h | Loading commit data... | |
| avx512pfintrin.h | Loading commit data... | |
| avx512vlbwintrin.h | Loading commit data... | |
| avx512vldqintrin.h | Loading commit data... | |
| avx512vlintrin.h | Loading commit data... | |
| avxintrin.h | Loading commit data... | |
| avxmath.h | Loading commit data... | |
| bdver1.md | Loading commit data... | |
| bdver3.md | Loading commit data... | |
| biarch64.h | Loading commit data... | |
| biarchx32.h | Loading commit data... | |
| bmi2intrin.h | Loading commit data... | |
| bmiintrin.h | Loading commit data... | |
| bmmintrin.h | Loading commit data... | |
| bsd.h | Loading commit data... | |
| btver2.md | Loading commit data... | |
| clflushoptintrin.h | Loading commit data... | |
| constraints.md | Loading commit data... | |
| core2.md | Loading commit data... | |
| cpuid.h | Loading commit data... | |
| cross-stdarg.h | Loading commit data... | |
| crtdll.h | Loading commit data... | |
| cygming.h | Loading commit data... | |
| cygming.opt | Loading commit data... | |
| cygwin-stdint.h | Loading commit data... | |
| cygwin-w64.h | Loading commit data... | |
| cygwin.h | Loading commit data... | |
| cygwin.opt | Loading commit data... | |
| darwin.h | Loading commit data... | |
| darwin64.h | Loading commit data... | |
| djgpp-stdint.h | Loading commit data... | |
| djgpp.h | Loading commit data... | |
| djgpp.opt | Loading commit data... | |
| dragonfly.h | Loading commit data... | |
| driver-i386.c | Loading commit data... | |
| emmintrin.h | Loading commit data... | |
| f16cintrin.h | Loading commit data... | |
| fma4intrin.h | Loading commit data... | |
| fmaintrin.h | Loading commit data... | |
| freebsd.h | Loading commit data... | |
| freebsd64.h | Loading commit data... | |
| fxsrintrin.h | Loading commit data... | |
| gas.h | Loading commit data... | |
| geode.md | Loading commit data... | |
| gmm_malloc.h | Loading commit data... | |
| gnu-user-common.h | Loading commit data... | |
| gnu-user.h | Loading commit data... | |
| gnu-user64.h | Loading commit data... | |
| gnu.h | Loading commit data... | |
| gstabs.h | Loading commit data... | |
| host-cygwin.c | Loading commit data... | |
| host-i386-darwin.c | Loading commit data... | |
| host-mingw32.c | Loading commit data... | |
| i386-builtin-types.awk | Loading commit data... | |
| i386-builtin-types.def | Loading commit data... | |
| i386-c.c | Loading commit data... | |
| i386-interix.h | Loading commit data... | |
| i386-modes.def | Loading commit data... | |
| i386-opts.h | Loading commit data... | |
| i386-protos.h | Loading commit data... | |
| i386.c | Loading commit data... | |
| i386.h | Loading commit data... | |
| i386.md | Loading commit data... | |
| i386.opt | Loading commit data... | |
| i386elf.h | Loading commit data... | |
| ia32intrin.h | Loading commit data... | |
| immintrin.h | Loading commit data... | |
| interix.opt | Loading commit data... | |
| k6.md | Loading commit data... | |
| kfreebsd-gnu.h | Loading commit data... | |
| kfreebsd-gnu64.h | Loading commit data... | |
| knetbsd-gnu.h | Loading commit data... | |
| kopensolaris-gnu.h | Loading commit data... | |
| linux-common.h | Loading commit data... | |
| linux.h | Loading commit data... | |
| linux64.h | Loading commit data... | |
| lwpintrin.h | Loading commit data... | |
| lynx.h | Loading commit data... | |
| lzcntintrin.h | Loading commit data... | |
| mingw-pthread.h | Loading commit data... | |
| mingw-stdint.h | Loading commit data... | |
| mingw-w64.h | Loading commit data... | |
| mingw-w64.opt | Loading commit data... | |
| mingw.opt | Loading commit data... | |
| mingw32.h | Loading commit data... | |
| mm3dnow.h | Loading commit data... | |
| mmintrin.h | Loading commit data... | |
| mmx.md | Loading commit data... | |
| msformat-c.c | Loading commit data... | |
| netbsd-elf.h | Loading commit data... | |
| netbsd64.h | Loading commit data... | |
| nmmintrin.h | Loading commit data... | |
| nto.h | Loading commit data... | |
| nto.opt | Loading commit data... | |
| openbsd.h | Loading commit data... | |
| openbsdelf.h | Loading commit data... | |
| pentium.md | Loading commit data... | |
| pmm_malloc.h | Loading commit data... | |
| pmmintrin.h | Loading commit data... | |
| popcntintrin.h | Loading commit data... | |
| ppro.md | Loading commit data... | |
| predicates.md | Loading commit data... | |
| prfchwintrin.h | Loading commit data... | |
| rdos.h | Loading commit data... | |
| rdos64.h | Loading commit data... | |
| rdseedintrin.h | Loading commit data... | |
| rtemself.h | Loading commit data... | |
| rtmintrin.h | Loading commit data... | |
| shaintrin.h | Loading commit data... | |
| slm.md | Loading commit data... | |
| smmintrin.h | Loading commit data... | |
| sol2.h | Loading commit data... | |
| sse.md | Loading commit data... | |
| ssemath.h | Loading commit data... | |
| stringop.def | Loading commit data... | |
| stringop.opt | Loading commit data... | |
| subst.md | Loading commit data... | |
| sync.md | Loading commit data... | |
| sysv4.h | Loading commit data... | |
| t-cygming | Loading commit data... | |
| t-cygwin-w64 | Loading commit data... | |
| t-darwin | Loading commit data... | |
| t-darwin64 | Loading commit data... | |
| t-gmm_malloc | Loading commit data... | |
| t-gnu | Loading commit data... | |
| t-i386 | Loading commit data... | |
| t-interix | Loading commit data... | |
| t-kfreebsd | Loading commit data... | |
| t-linux | Loading commit data... | |
| t-linux64 | Loading commit data... | |
| t-mingw-w32 | Loading commit data... | |
| t-mingw-w64 | Loading commit data... | |
| t-openbsd | Loading commit data... | |
| t-pmm_malloc | Loading commit data... | |
| t-rtems | Loading commit data... | |
| t-sol2 | Loading commit data... | |
| t-vxworks | Loading commit data... | |
| t-vxworksae | Loading commit data... | |
| tbmintrin.h | Loading commit data... | |
| tmmintrin.h | Loading commit data... | |
| unix.h | Loading commit data... | |
| vxworks.h | Loading commit data... | |
| vxworksae.h | Loading commit data... | |
| winnt-cxx.c | Loading commit data... | |
| winnt-stubs.c | Loading commit data... | |
| winnt.c | Loading commit data... | |
| wmmintrin.h | Loading commit data... | |
| x-cygwin | Loading commit data... | |
| x-darwin | Loading commit data... | |
| x-i386 | Loading commit data... | |
| x-mingw32 | Loading commit data... | |
| x86-64.h | Loading commit data... | |
| x86-tune.def | Loading commit data... | |
| x86intrin.h | Loading commit data... | |
| xm-cygwin.h | Loading commit data... | |
| xm-djgpp.h | Loading commit data... | |
| xm-mingw32.h | Loading commit data... | |
| xmmintrin.h | Loading commit data... | |
| xopintrin.h | Loading commit data... | |
| xsavecintrin.h | Loading commit data... | |
| xsaveintrin.h | Loading commit data... | |
| xsaveoptintrin.h | Loading commit data... | |
| xsavesintrin.h | Loading commit data... | |
| xtestintrin.h | Loading commit data... |