[committed] Add --import-optimize/--no-import-optimize

Tom de Vries tdevries@suse.de
Wed Jan 1 00:00:00 GMT 2020


Hi,

The function create_import_tree attempts to reduce the number of
DW_TAG_imported_unit DIEs.

Add command line options --import-optimize/--no-opt-importize to control this
optimization.

Committed to trunk.

Thanks,
- Tom

Add --import-optimize/--no-import-optimize

2020-01-24  Tom de Vries  <tdevries@suse.de>

	* dwz.1: Add --import-optimize/--no-import-optimize entry.
	* dwz.c (import_opt_p): New variable.
	(create_import_tree): 	Move freeing of seen variable to ASAP instead
	of ALAP.  Guard optimization part with import_opt_p.
	(dwz_options, dwz_common_options_help): Add
	--import-optimize/--no-import-optimize.

---
 dwz.1 |  8 ++++++++
 dwz.c | 17 +++++++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/dwz.1 b/dwz.1
index 3df7e59..b48bc02 100644
--- a/dwz.1
+++ b/dwz.1
@@ -105,6 +105,14 @@ In normal operation, the link setting should be used.  The basic setting is
 provided only as fallback in case of problems with the link setting.  Set to
 link by default.
 .TP
+.B \-\-import-optimize / \-\-no-import-optimize
+Enable/disable optimization that reduces the number of
+\fIDW_TAG_imported_unit\fR DIEs generated to import the partial units created
+by \fBdwz\fR.  Disabling the optimization can be used to work around problems
+in the optimization, or to make it easier to observe which CU imports which
+PU.
+Enabled by default.
+.TP
 .B \-? \-\-help
 Print short help and exit.
 .TP
diff --git a/dwz.c b/dwz.c
index a81e42a..bffbaa1 100644
--- a/dwz.c
+++ b/dwz.c
@@ -210,6 +210,7 @@ static int verify_edges_p = 0;
 static int dump_edges_p = 0;
 static int partition_dups_opt;
 static int progress_p;
+static int import_opt_p = 1;
 enum die_count_methods
 {
   none,
@@ -7859,6 +7860,8 @@ create_import_tree (void)
     dump_edges ("phase 1", ipus, npus, ncus);
   if (unlikely (verify_edges_p))
     verify_edges (ipus, npus, ncus, 1);
+  if (!import_opt_p)
+    goto opt_done;
   if (unlikely (progress_p))
     {
       report_progress ();
@@ -8371,10 +8374,12 @@ create_import_tree (void)
 	  max_seen = 0;
 	}
     }
+  free (seen);
   if (unlikely (dump_edges_p))
     dump_edges ("phase 3", ipus, npus, ncus);
   if (unlikely (verify_edges_p))
     verify_edges (ipus, npus, ncus, 3);
+ opt_done:
   if (unlikely (progress_p))
     {
       report_progress ();
@@ -8457,7 +8462,6 @@ create_import_tree (void)
     for (cu = alt_first_cu; cu; cu = cu->cu_next)
       cu->u1.cu_icu = NULL;
   obstack_free (&ob2, to_free);
-  free (seen);
   return 0;
 }
 
@@ -14451,6 +14455,10 @@ static struct option dwz_options[] =
   { "multifile-name",	 required_argument, 0, 'M' },
   { "relative",		 no_argument,	    0, 'r' },
   { "version",		 no_argument,	    0, 'v' },
+  { "import-optimization",
+			 no_argument,	    &import_opt_p, 1 },
+  { "no-import-optimization",
+			 no_argument,	    &import_opt_p, 0 },
 #if DEVEL
   { "devel-trace",	 no_argument,	    &tracing, 1 },
   { "devel-progress",	 no_argument,	    &progress_p, 1 },
@@ -14502,7 +14510,12 @@ static struct option_help dwz_common_options_help[] =
   { NULL, "no-odr", NULL, "Enabled",
     "Enable/disable one definition rule optimization." },
   { NULL, "odr-mode", "<basic|link>", "link",
-    "Set aggressiveness level of one definition rule optimization." }
+    "Set aggressiveness level of one definition rule optimization." },
+  { NULL, "import-optimization", NULL, NULL,
+    NULL },
+  { NULL, "no-import-optimization", NULL, "Enabled",
+    "Enable/disable optimization that reduces the number of"
+    " DW_TAG_imported_unit DIEs." }
 };
 
 /* Describe single-file command line options.  */



More information about the Dwz mailing list