https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83660
Will Schmidt <willschm at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |willschm at gcc dot gnu.org --- Comment #7 from Will Schmidt <willschm at gcc dot gnu.org> --- The ICE is triggered on the gcc_unreachable() at the bottom of the switch(gimple_code(stmt)) clause in gimple-low.c: lower_stmt(). We enter the switch with our gimple_code(stmt) == GIMPLE_WITH_CLEANUP_EXPR. # cfun at this point is: (gdb) pcfun get_word (__vector __bool int v) { unsigned int D.3236; { const unsigned int _B2; _B2 = 32; D.3235 = v; <<< Unknown GIMPLE statement: gimple_with_cleanup_expr >>> retval.0 = BIT_FIELD_REF <D.3235, 32, 64>; } D.3236 = retval.0; return D.3236; } Doing some code-browsing, I see some logic to handle GIMPLE_WITH_CLEANUP_EXPR in remap_gimple_stmt() and in gimple_copy() , but not in lower_stmt(). However, at gimplify.c: gimplify_cleanup_point_expr() i see the comment: /* Gimplify a CLEANUP_POINT_EXPR. Currently this works by adding GIMPLE_WITH_CLEANUP_EXPRs to the prequeue as we encounter cleanups while gimplifying the body, and converting them to TRY_FINALLY_EXPRs when we return to this function. Debug on the logic there... for (iter = gsi_start (body_sequence); !gsi_end_p (iter); ) { gimple *wce = gsi_stmt (iter); if (gimple_code (wce) == GIMPLE_WITH_CLEANUP_EXPR) does not show any matches with GIMPLE_WITH_CLEANUP_EXPR. (one GIMPLE_ASSIGN, 3 GIMPLE_BIND). so we're not catching and generating TRY_FINALLY_EXPRS on the way out like we want or need to. (I can scratch and dig around some more,.. but could use a hint or do a hand-off to someone.. :-) Additional debug, possibly not relevant: During (first?) gimple pass, we get to gimple_build_wce by way of multiple calls through .. hard to paraphrase, heres the bt. (gdb) bt #0 0x000000001088da08 in gimple_build_wce (cleanup=0x1000009e00f0) at gimple.c:742 #1 0x00000000108e9984 in gimple_push_cleanup (var=0x100000080a20, cleanup=<optimized out>, eh_only=false, pre_p=0x3fffffffd7a0, force_uncond=true) at gimplify.c:6528 #2 0x00000000108f7cbc in gimplify_target_expr (expr_p=0x1000006b0d38, pre_p=0x3fffffffd7a0, post_p=0x3fffffffd390) at gimplify.c:6611 #3 0x00000000108e3410 in gimplify_expr (expr_p=0x1000006b0d38, pre_p=0x3fffffffd7a0, post_p=0x3fffffffd390, gimple_test_f=0x1089b130 <is_gimple_lvalue(tree_node*)>, fallback=<optimized out>) at gimplify.c:11815 #4 0x00000000108e2f28 in gimplify_expr (expr_p=0x1000008c8e50, pre_p=0x3fffffffd7a0, post_p=0x3fffffffd390, gimple_test_f=0x108d1660 <is_gimple_reg_rhs_or_call(tree)>, fallback=1) at gimplify.c:11739 #5 0x00000000108f9cdc in gimplify_modify_expr (expr_p=0x1000006ff598, pre_p=0x3fffffffd7a0, post_p=0x3fffffffd390, want_value=false) at gimplify.c:5626 #6 0x00000000108e3430 in gimplify_expr (expr_p=0x1000006ff598, pre_p=0x3fffffffd7a0, post_p=0x3fffffffd390, gimple_test_f=0x108d6cc0 <is_gimple_stmt(tree)>, fallback=0) at gimplify.c:11435 #7 0x00000000108e7288 in gimplify_stmt (stmt_p=<optimized out>, seq_p=0x3fffffffd7a0) at gimplify.c:6658 #8 0x00000000108e402c in gimplify_statement_list (pre_p=<optimized out>, expr_p=0x1000006b0c80) at gimplify.c:1767 #9 gimplify_expr (expr_p=0x1000006b0c80, pre_p=0x3fffffffd7a0, post_p=0x3fffffffd5c0, gimple_test_f=0x108d6cc0 <is_gimple_stmt(tree)>, fallback=0) at gimplify.c:11863 #10 0x00000000108e72dc in gimplify_stmt (stmt_p=0x1000006b0c80, seq_p=0x3fffffffd7a0) at gimplify.c:6658 #11 0x00000000108e8b8c in gimplify_bind_expr (expr_p=0x1000008c8e00, pre_p=0x3fffffffe0d0) at gimplify.c:1335 #12 0x00000000108e31ec in gimplify_expr (expr_p=0x1000008c8e00, pre_p=0x3fffffffe0d0, post_p=0x3fffffffdc20, gimple_test_f=0x108d1660 <is_gimple_reg_rhs_or_call(tree)>, fallback=1) at gimplify.c:11635 #13 0x00000000108f9cdc in gimplify_modify_expr (expr_p=0x3fffffffde70, pre_p=0x3fffffffe0d0, post_p=0x3fffffffdc20, want_value=false) at gimplify.c:5626 #14 0x00000000108e3430 in gimplify_expr (expr_p=0x3fffffffde70, pre_p=0x3fffffffe0d0, post_p=0x3fffffffdc20, gimple_test_f=0x108d6cc0 <is_gimple_stmt(tree)>, fallback=0) at gimplify.c:11435 #15 0x00000000108e72dc in gimplify_stmt (stmt_p=0x3fffffffde70, seq_p=0x3fffffffe0d0) at gimplify.c:6658 #16 0x00000000108e3cc0 in gimplify_and_add (seq_p=0x3fffffffe0d0, t=<optimized out>) at gimplify.c:441 #17 gimplify_return_expr (pre_p=0x3fffffffe0d0, stmt=<optimized out>) at gimplify.c:1571 #18 gimplify_expr (expr_p=0x1000009b4bd8, pre_p=0x3fffffffe0d0, post_p=0x3fffffffde50, gimple_test_f=0x108d6cc0 <is_gimple_stmt(tree)>, fallback=0) at gimplify.c:11695 #19 0x00000000108e72dc in gimplify_stmt (stmt_p=<optimized out>, seq_p=0x3fffffffe0d0) at gimplify.c:6658 #20 0x00000000108e3050 in gimplify_cleanup_point_expr (pre_p=<optimized out>, expr_p=0x1000006b0cb0) at gimplify.c:6400 #21 gimplify_expr (expr_p=0x1000006b0cb0, pre_p=0x3fffffffe260, post_p=0x3fffffffe080, gimple_test_f=0x108d6cc0 <is_gimple_stmt(tree)>, fallback=0) at gimplify.c:11811 #22 0x00000000108e72dc in gimplify_stmt (stmt_p=0x1000006b0cb0, seq_p=0x3fffffffe260) at gimplify.c:6658 #23 0x00000000108e8b8c in gimplify_bind_expr (expr_p=0x100000965dc0, pre_p=0x3fffffffe5a0) at gimplify.c:1335 #24 0x00000000108e31ec in gimplify_expr (expr_p=0x100000965dc0, pre_p=0x3fffffffe5a0, post_p=0x3fffffffe3c0, gimple_test_f=0x108d6cc0 <is_gimple_stmt(tree)>, fallback=0) at gimplify.c:11635 #25 0x00000000108e72dc in gimplify_stmt (stmt_p=0x100000965dc0, seq_p=0x3fffffffe5a0) at gimplify.c:6658 #26 0x00000000108e9ba0 in gimplify_body (fndecl=0x100000965d00, do_parms=true) at gimplify.c:12635 #27 0x00000000108ea490 in gimplify_function_tree (fndecl=0x100000965d00) at gimplify.c:12800 #28 0x00000000106cf058 in cgraph_node::analyze (this=0x1000009d2b20) at cgraphunit.c:670 As we enter the gimple_build_wce() function,: Breakpoint 15, 0x000000001088da08 in gimple_build_wce (cleanup=0x1000009e00f0) at gimple.c:742 742 { "gimple_build_wce():" "p cleanup" $5 = (gimple_seq) 0x1000009e00f0 "pgq cleanup" warning: Expression is not an assignment (and might have no effect) D.3235 = {CLOBBER}; "pcfun" " get_word (__vector __bool int v) { <<cleanup_point return D.3236 = { const unsigned int _B2; retval.0 = BIT_FIELD_REF <TARGET_EXPR <D.3235, NON_LVALUE_EXPR <v>>, 32, 64>; }>>; } void " And at the end of the pass(?), our cfun reads: get_word (__vector __bool int v) { unsigned int D.3236; __bool int retval.0; __vector __bool int D.3235; { const unsigned int _B2; _B2 = 32; D.3235 = v; <<< Unknown GIMPLE statement: gimple_with_cleanup_expr >>> retval.0 = BIT_FIELD_REF <D.3235, 32, 64>; } D.3236 = retval.0; return D.3236; } void