From aa6b742f0fbdef0df7b45509e0af7593dd45e08a Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 26 Mar 2014 10:18:26 +0100 Subject: re PR sanitizer/60636 (ubsan doesn't instrument signed integer ABS_EXPR) PR sanitizer/60636 * ubsan.c (instrument_si_overflow): Instrument ABS_EXPR. * c-c++-common/ubsan/pr60636.c: New test. From-SVN: r208841 --- gcc/ubsan.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gcc/ubsan.c') diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 22470da..8a8c289 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -737,6 +737,21 @@ instrument_si_overflow (gimple_stmt_iterator gsi) gimple_call_set_lhs (g, lhs); gsi_replace (&gsi, g, false); break; + case ABS_EXPR: + /* Transform i = ABS_EXPR; + into + _N = UBSAN_CHECK_SUB (0, u); + i = ABS_EXPR<_N>; */ + a = build_int_cst (lhstype, 0); + b = gimple_assign_rhs1 (stmt); + g = gimple_build_call_internal (IFN_UBSAN_CHECK_SUB, 2, a, b); + a = make_ssa_name (lhstype, NULL); + gimple_call_set_lhs (g, a); + gimple_set_location (g, gimple_location (stmt)); + gsi_insert_before (&gsi, g, GSI_SAME_STMT); + gimple_assign_set_rhs1 (stmt, a); + update_stmt (stmt); + break; default: break; } -- cgit v1.1