public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
* [committed 8/13][odr] Add --odr/--no-odr and --odr-mode=<basic,link> command line options
@ 2020-01-01  0:00 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2020-01-01  0:00 UTC (permalink / raw)
  To: dwz, jakub

Hi,

Add optimization options --odr/--no-odr and --odr-mode=<basic|link>, making
the optimization user accessible.

Committed to trunk.

Thanks,
- Tom

[odr] Add --odr/--no-odr and --odr-mode=<basic,link> command line options

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

	* dwz.c (odr_parsed, no_odr_parsed, int odr_mode_parsed): New variable.
	(dwz_options, dwz_common_options_help): Add --odr, --no-odr and
	--odr-mode entries.
	(print_options_help): Allow entries with NULL short_name and NULL msg.
	(main): Handle --odr, --no-odr and --odr-mode.

---
 dwz.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 65 insertions(+), 15 deletions(-)

diff --git a/dwz.c b/dwz.c
index 661cdb0..277c61d 100644
--- a/dwz.c
+++ b/dwz.c
@@ -216,6 +216,9 @@ static enum die_count_methods die_count_method = estimate;
 int odr = 0;
 enum odr_mode { ODR_BASIC, ODR_LINK };
 enum odr_mode odr_mode = ODR_LINK;
+int odr_parsed = 0;
+int no_odr_parsed = 0;
+int odr_mode_parsed = 0;
 
 typedef struct
 {
@@ -14161,6 +14164,9 @@ static struct option dwz_options[] =
   { "devel-die-count-method",
 			 required_argument, &die_count_method_parsed, 1 },
 #endif
+  { "odr",		 no_argument,	    &odr_parsed, 1 },
+  { "no-odr",		 no_argument,	    &no_odr_parsed, 1 },
+  { "odr-mode",		 required_argument, &odr_mode_parsed, 1 },
   { NULL,		 no_argument,	    0, 0 }
 };
 
@@ -14183,7 +14189,13 @@ static struct option_help dwz_common_options_help[] =
     "Handle files larger than this limit using a slower and more memory"
     " usage friendly mode and don't optimize those files in multifile mode." },
   { "L", "max-die-limit", "<COUNT|none>", "50 million DIEs",
-    "Don't optimize files larger than this limit." }
+    "Don't optimize files larger than this limit." },
+  { NULL, "odr", NULL, NULL,
+    NULL },
+  { 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." }
 };
 
 /* Describe single-file command line options.  */
@@ -14292,12 +14304,20 @@ print_options_help (struct option_help *options_help, unsigned int n,
       len += 2;
 
       s = options_help[i].short_name;
-      fprintf (stderr, "-%s", s);
-      len += 2;
+      if (s)
+	{
+	  fprintf (stderr, "-%s", s);
+	  len += 2;
+	}
 
       s = options_help[i].long_name;
-      fprintf (stderr, ", --%s", s);
-      len += 4 + strlen (s);
+      if (len == 4)
+	{
+	  fprintf (stderr, ", ");
+	  len += 2;
+	}
+      fprintf (stderr, "--%s", s);
+      len += 2 + strlen (s);
 
       s = options_help[i].argument;
       if (s)
@@ -14306,18 +14326,20 @@ print_options_help (struct option_help *options_help, unsigned int n,
 	  len += 1 + strlen (s);
 	}
 
-      if (len > indent)
-	{
-	  fprintf (stderr, "\n");
-	  do_indent (indent);
-	}
-      else
-	do_indent (indent - len);
-      len = indent;
-
       s = options_help[i].msg;
-      wrap (indent, limit, s);
+      if (s)
+	{
+	  if (len > indent)
+	    {
+	      fprintf (stderr, "\n");
+	      do_indent (indent);
+	    }
+	  else
+	    do_indent (indent - len);
+	  len = indent;
 
+	  wrap (indent, limit, s);
+	}
       fprintf (stderr, "\n");
 
       s = options_help[i].default_value;
@@ -14448,6 +14470,34 @@ main (int argc, char *argv[])
 	      error (1, 0, "invalid argument --devel-die-count-method %s",
 		     optarg);
 	    }
+	  if (odr_parsed)
+	    {
+	      assert (!no_odr_parsed);
+	      odr = 1;
+	      odr_parsed = 0;
+	    }
+	  if (no_odr_parsed)
+	    {
+	      assert (!odr_parsed);
+	      odr = 0;
+	      no_odr_parsed = 0;
+	    }
+	  if (odr_mode_parsed)
+	    {
+	      odr_mode_parsed = 0;
+	      if (strcmp (optarg, "basic") == 0)
+		{
+		  odr_mode = ODR_BASIC;
+		  break;
+		}
+	      if (strcmp (optarg, "link") == 0)
+		{
+		  odr_mode = ODR_LINK;
+		  break;
+		}
+	      error (1, 0, "invalid argument --odr-mode %s",
+		     optarg);
+	    }
 	  break;
 
 	case 'o':

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-01-06 16:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-01  0:00 [committed 8/13][odr] Add --odr/--no-odr and --odr-mode=<basic,link> command line options Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).