From 171a55e7f52c1e51a85ce0e4dad550c310d1030e Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Wed, 15 Nov 2017 03:11:48 +0000 Subject: [PATCH] introduce TDF_compare_debug, omit OBJ_TYPE_REF casts with it for gcc/ChangeLog * dumpfile.h (TDF_COMPARE_DEBUG): New. * final.c (rest_of_clean_state): Set it for the -fcompare-debug dump. * tree-pretty-print.c (dump_generic_node): Omit OBJ_TYPE_REF class when TDF_COMPARE_DEBUG is set. From-SVN: r254751 --- gcc/ChangeLog | 6 ++++++ gcc/dumpfile.h | 1 + gcc/final.c | 2 +- gcc/tree-pretty-print.c | 10 +++++++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 70ae417b366..9cba109ec59 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2017-11-15 Alexandre Oliva + * dumpfile.h (TDF_COMPARE_DEBUG): New. + * final.c (rest_of_clean_state): Set it for the + -fcompare-debug dump. + * tree-pretty-print.c (dump_generic_node): Omit OBJ_TYPE_REF + class when TDF_COMPARE_DEBUG is set. + * dwarf2out.c (gen_producer_string): Discard OPT_fcompare_debug. diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h index 4d9f6b3656a..1b4d7e7dab7 100644 --- a/gcc/dumpfile.h +++ b/gcc/dumpfile.h @@ -93,6 +93,7 @@ enum dump_kind #define MSG_NOTE (1 << 24) /* general optimization info */ #define MSG_ALL (MSG_OPTIMIZED_LOCATIONS | MSG_MISSED_OPTIMIZATION \ | MSG_NOTE) +#define TDF_COMPARE_DEBUG (1 << 25) /* Dumping for -fcompare-debug. */ /* Value of TDF_NONE is used just for bits filtered by TDF_KIND_MASK. */ diff --git a/gcc/final.c b/gcc/final.c index 039c37a3135..fe35a36dbbf 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -4629,7 +4629,7 @@ rest_of_clean_state (void) { flag_dump_noaddr = flag_dump_unnumbered = 1; if (flag_compare_debug_opt || flag_compare_debug) - dump_flags |= TDF_NOUID; + dump_flags |= TDF_NOUID | TDF_COMPARE_DEBUG; dump_function_header (final_output, current_function_decl, dump_flags); final_insns_dump_p = true; diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 61a28c6757f..80d45f96d67 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -2760,7 +2760,15 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, pp_string (pp, "OBJ_TYPE_REF("); dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false); pp_semicolon (pp); - if (!(flags & TDF_SLIM) && virtual_method_call_p (node)) + /* We omit the class type for -fcompare-debug because we may + drop TYPE_BINFO early depending on debug info, and then + virtual_method_call_p would return false, whereas when + TYPE_BINFO is preserved it may still return true and then + we'd print the class type. Compare tree and rtl dumps for + libstdc++-prettyprinters/shared_ptr.cc with and without -g, + for example, at occurrences of OBJ_TYPE_REF. */ + if (!(flags & (TDF_SLIM | TDF_COMPARE_DEBUG)) + && virtual_method_call_p (node)) { pp_string (pp, "("); dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false); -- 2.30.2