From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 71224 invoked by alias); 13 Feb 2020 18:00:06 -0000 Mailing-List: contact dwz-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: dwz-owner@sourceware.org Received: (qmail 71176 invoked by uid 89); 13 Feb 2020 18:00:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=Detected, 5610,6, 56106, odr X-Spam-Status: No, score=-25.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: mx2.suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Date: Wed, 01 Jan 2020 00:00:00 -0000 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com Subject: [committed][odr] Guard odr code with odr_active_p Message-ID: <20200213175958.GA14390@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-SW-Source: 2020-q1/txt/msg00069.txt Hi, The odr optimization is enabled by the odr variable. When enabled, some DIEs will get an die_odr_state of ODR_DEF or ODR_DECL, which is then handled further by code guarded with odr. However, it may be the case that all DIEs were marked with ODR_NONE, because: - read_debug_info was run in low-mem mode, or - read_debug_info was run in optimize-multifile mode, or - there were no DIEs for which the optimization was applicable. If all DIEs were marked with ODR_NONE, there is no point in entering further odr handling code. Add a variable odr_active_p that is set to true when at least one DIE has an die_odr_state that is not ODR_NONE, and use the variable to guard some odr code. Committed to trunk. Thanks, - Tom [odr] Guard odr code with odr_active_p 2020-02-13 Tom de Vries * dwz.c (odr_active_p): New var. (set_die_odr_state): Set odr_active_p to true. (read_debug_info): Initialize odr_active_p to false. (partition_dups_1, partition_dups): Use odr_active_p instead of odr. --- dwz.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dwz.c b/dwz.c index f08bf4e..0c13682 100644 --- a/dwz.c +++ b/dwz.c @@ -223,6 +223,7 @@ int odr = 1; enum odr_mode { ODR_BASIC, ODR_LINK }; enum odr_mode odr_mode = ODR_LINK; int odr_mode_parsed = 0; +bool odr_active_p = false; /* Struct to gather statistics. */ struct stats @@ -2544,6 +2545,8 @@ set_die_odr_state (dw_cu_ref cu, dw_die_ref die) /* Ignore anonymous types. */ return; + odr_active_p = true; + if (decl_p && !other_p && die->die_child == NULL) { /* Detected a declaration with no attributes other than DW_AT_name and @@ -5610,6 +5613,7 @@ read_debug_info (DSO *dso, int kind, unsigned int *die_count) struct dw_cu cu_buf; struct dw_die die_buf; + odr_active_p = false; if (odr) odr_phase = 1; @@ -6958,7 +6962,7 @@ partition_dups_1 (dw_die_ref *arr, size_t vec_size, dw_die_ref child; if (second_phase && !arr[k]->die_ref_seen) continue; - if (odr && odr_mode != ODR_BASIC) + if (odr_active_p && odr_mode != ODR_BASIC) arr[k] = reorder_dups (arr[k]); if (dump_pus_p) dump_die (arr[k]); @@ -7113,14 +7117,14 @@ partition_dups (void) to_free = obstack_alloc (&ob2, 1); - if (odr) + if (odr_active_p) odr_phase = 2; for (cu = first_cu; cu; cu = cu->cu_next) partition_find_dups (&ob2, cu->cu_die); vec_size = obstack_object_size (&ob2) / sizeof (void *); - if (odr) + if (odr_active_p) { arr = (dw_die_ref *) obstack_base (&ob2); if (progress_p) @@ -7170,7 +7174,7 @@ partition_dups (void) vec_size = obstack_object_size (&ob2) / sizeof (void *); } - if (odr) + if (odr_active_p) odr_phase = 3; if (stats_p) @@ -7179,7 +7183,7 @@ partition_dups (void) if (vec_size != 0) { arr = (dw_die_ref *) obstack_finish (&ob2); - if (odr) + if (odr_active_p) for (i = 0; i < vec_size; ++i) { assert (arr[i] != NULL);