[PATCH, v3] Fix PR51513, switch statement with default case containing __builtin_unreachable leads to wild branch
Peter Bergner
bergner@vnet.ibm.com
Thu Apr 27 15:16:00 GMT 2017
On 4/27/17 6:57 AM, Bernhard Reutner-Fischer wrote:
> On Wed, Apr 26, 2017 at 10:39:12PM -0500, Peter Bergner wrote:
>> +/* Returns true if the basic block BB has no successors and only contains
>> + a call to __builtin_unreachable (). */
>
> so
> return EDGE_COUNT (bb->succs) == 0
> && (gsi = gsi_last_nondebug_bb (bb))
> && !gsi_end_p (gsi)
> && gimple_call_builtin_p (gsi_stmt (gsi), BUILT_IN_UNREACHABLE);
[snip]
> which i should better phrase as
> gsi = gsi_start_nondebug_after_labels_bb (bb);
> while (!gsi_end_p (gsi)
> {
> gimple *stmt = gsi_stmt (gsi);
> if (gimple_clobber_p (stmt))
> gsi_next (&gsi);
> else
> return gimple_call_builtin_p (stmt, BUILT_IN_UNREACHABLE);
> }
> return false;
I didn't try to rewrite the code too much, I basically just outlined
the code as is. However, one change I did have to make, was to not
use routines like gsi_after_labels(), etc., since those do not work
during expansion to RTL, due to bb->flags == BB_RTL. Those off limits
routines include gsi_start_nondebug_after_labels_bb(), since it calls
gsi_after_labels().
Peter
More information about the Gcc-patches
mailing list