From 1b0be822208349b2795381deace2352e998c1ad0 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Mon, 17 Aug 2020 11:53:45 -0400 Subject: [PATCH] analyzer: fix ICE on unhandled tree codes in gassign [PR96640] PR analyzer/96640 reports a ICE within region_model::on_assignment when failing to handle a WIDEN_MULT_EVEN_EXPR, and various other tree codes. The old implementation of region_model::on_assignment gracefully handled tree codes it didn't understand, returning "UNKNOWN", whereas the new implementation (r11-2694-g808f4dfeb3a95f50f15e71148e5c1067f90a126d) had a "sorry_at" and an assertion left over from development, leading to ICEs. This patch restores the old behavior for these cases, and marks various vector operations as leading to unknown results. gcc/analyzer/ChangeLog: PR analyzer/96640 * region-model.cc (region_model::get_gassign_result): Handle various VEC_* tree codes by returning UNKNOWN. (region_model::on_assignment): Handle unrecognized tree codes by setting lhs to an unknown value, rather than issuing a "sorry" and asserting. --- gcc/analyzer/region-model.cc | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index 3c7ea40..cd74c0f 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -526,6 +526,22 @@ region_model::get_gassign_result (const gassign *assign, case VEC_SERIES_EXPR: case VEC_COND_EXPR: case VEC_PERM_EXPR: + case VEC_WIDEN_MULT_HI_EXPR: + case VEC_WIDEN_MULT_LO_EXPR: + case VEC_WIDEN_MULT_EVEN_EXPR: + case VEC_WIDEN_MULT_ODD_EXPR: + case VEC_UNPACK_HI_EXPR: + case VEC_UNPACK_LO_EXPR: + case VEC_UNPACK_FLOAT_HI_EXPR: + case VEC_UNPACK_FLOAT_LO_EXPR: + case VEC_UNPACK_FIX_TRUNC_HI_EXPR: + case VEC_UNPACK_FIX_TRUNC_LO_EXPR: + case VEC_PACK_TRUNC_EXPR: + case VEC_PACK_SAT_EXPR: + case VEC_PACK_FIX_TRUNC_EXPR: + case VEC_PACK_FLOAT_EXPR: + case VEC_WIDEN_LSHIFT_HI_EXPR: + case VEC_WIDEN_LSHIFT_LO_EXPR: return m_mgr->get_or_create_unknown_svalue (TREE_TYPE (lhs)); } } @@ -555,10 +571,12 @@ region_model::on_assignment (const gassign *assign, region_model_context *ctxt) { default: { - if (1) + if (0) sorry_at (assign->location, "unhandled assignment op: %qs", get_tree_code_name (op)); - gcc_unreachable (); + const svalue *unknown_sval + = m_mgr->get_or_create_unknown_svalue (TREE_TYPE (lhs)); + set_value (lhs_reg, unknown_sval, ctxt); } break; -- 2.7.4