This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Optimize location expansion in lto type location compare


Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2018-06-05  Richard Biener  <rguenther@suse.de>

	* lto.c (cmp_type_location): Expand locations only once.

Index: gcc/lto/lto.c
===================================================================
--- gcc/lto/lto.c	(revision 261193)
+++ gcc/lto/lto.c	(working copy)
@@ -1707,23 +1707,19 @@ cmp_type_location (const void *p1_, cons
 
   tree tname1 = TYPE_NAME (*p1);
   tree tname2 = TYPE_NAME (*p2);
+  expanded_location xloc1 = expand_location (DECL_SOURCE_LOCATION (tname1));
+  expanded_location xloc2 = expand_location (DECL_SOURCE_LOCATION (tname2));
 
-  const char *f1 = DECL_SOURCE_FILE (tname1);
-  const char *f2 = DECL_SOURCE_FILE (tname2);
-
+  const char *f1 = lbasename (xloc1.file);
+  const char *f2 = lbasename (xloc2.file);
   int r = strcmp (f1, f2);
   if (r == 0)
     {
-      int l1 = DECL_SOURCE_LINE (tname1);
-      int l2 = DECL_SOURCE_LINE (tname2);
-      if (l1 == l2)
-       {
-	 int l1 = DECL_SOURCE_COLUMN (tname1);
-	 int l2 = DECL_SOURCE_COLUMN (tname2);
-	 return l1 - l2;
-       }
-      else
-       return l1 - l2;
+      int l1 = xloc1.line;
+      int l2 = xloc2.line;
+      if (l1 != l2)
+	return l1 - l2;
+      return xloc1.column - xloc2.column;
     }
   else
     return r;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]