[PATCH] D53683: [ELF] Add --{, no-}call-graph-profile-sort (enabled by default)

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 25 13:35:25 PDT 2018


MaskRay updated this revision to Diff 171178.
MaskRay added a comment.

Revert a comment change


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D53683

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/Options.td
  test/ELF/cgprofile-obj-warn.s


Index: test/ELF/cgprofile-obj-warn.s
===================================================================
--- test/ELF/cgprofile-obj-warn.s
+++ test/ELF/cgprofile-obj-warn.s
@@ -28,7 +28,10 @@
 
 # CHECK: unable to order absolute symbol: B
 
-# RUN: ld.lld %t -o /dev/null \
-# RUN:   -noinhibit-exec -icf=all --no-warn-symbol-ordering 2>&1 \
-# RUN:   | FileCheck %s --check-prefix=NOWARN
+# No warnings if --no-call-graph-profile-sort or --no-warn-symbol-ordering
+
+# RUN: ld.lld --no-warn-symbol-ordering %t -o /dev/null \
+# RUN:   --noinhibit-exec --icf=all 2>&1 | FileCheck %s --check-prefix=NOWARN
+# RUN: ld.lld --no-call-graph-profile-sort %t -o /dev/null \
+# RUN:   --noinhibit-exec --icf=all 2>&1 | FileCheck %s --check-prefix=NOWARN
 # NOWARN-NOT: unable to order
Index: ELF/Options.td
===================================================================
--- ELF/Options.td
+++ ELF/Options.td
@@ -74,6 +74,10 @@
 defm call_graph_ordering_file:
   Eq<"call-graph-ordering-file", "Layout sections to optimize the given callgraph">;
 
+defm call_graph_profile_sort: B<"call-graph-profile-sort",
+    "Reorder sections with call graph profile (default)",
+    "Do not reorder sections with call graph profile">;
+
 // -chroot doesn't have a help text because it is an internal option.
 def chroot: Separate<["--", "-"], "chroot">;
 
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -786,6 +786,8 @@
   Config->EhFrameHdr =
       Args.hasFlag(OPT_eh_frame_hdr, OPT_no_eh_frame_hdr, false);
   Config->EmitRelocs = Args.hasArg(OPT_emit_relocs);
+  Config->CallGraphProfileSort = Args.hasFlag(
+      OPT_call_graph_profile_sort, OPT_no_call_graph_profile_sort, true);
   Config->EnableNewDtags =
       Args.hasFlag(OPT_enable_new_dtags, OPT_disable_new_dtags, true);
   Config->Entry = Args.getLastArgValue(OPT_entry);
@@ -1637,10 +1639,12 @@
   }
 
   // Read the callgraph now that we know what was gced or icfed
-  if (auto *Arg = Args.getLastArg(OPT_call_graph_ordering_file))
-    if (Optional<MemoryBufferRef> Buffer = readFile(Arg->getValue()))
-      readCallGraph(*Buffer);
-  readCallGraphsFromObjectFiles<ELFT>();
+  if (Config->CallGraphProfileSort) {
+    if (auto *Arg = Args.getLastArg(OPT_call_graph_ordering_file))
+      if (Optional<MemoryBufferRef> Buffer = readFile(Arg->getValue()))
+        readCallGraph(*Buffer);
+    readCallGraphsFromObjectFiles<ELFT>();
+  }
 
   // Write the result to the file.
   writeResult<ELFT>();
Index: ELF/Config.h
===================================================================
--- ELF/Config.h
+++ ELF/Config.h
@@ -127,6 +127,7 @@
   bool AsNeeded = false;
   bool Bsymbolic;
   bool BsymbolicFunctions;
+  bool CallGraphProfileSort;
   bool CheckSections;
   bool CompressDebugSections;
   bool Cref;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53683.171178.patch
Type: text/x-patch
Size: 2852 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181025/0571af72/attachment.bin>


More information about the llvm-commits mailing list