[PATCH] D137620: [BOLT] Don't align .text to pageAlign

Denis Revunov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 8 01:27:52 PST 2022


treapster created this revision.
treapster added a project: bolt.
Herald added a reviewer: rafauler.
Herald added a subscriber: ayermolo.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
treapster requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.

Setting alignment of .text to PageAlign results in a wasted space of 2mb(or 4kb with -no-huge-pages) after program header table.
I think it doesn't make sense to align text to such a huge values, and aligning the segment itself is enough.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137620

Files:
  bolt/lib/Rewrite/MachORewriteInstance.cpp
  bolt/lib/Rewrite/RewriteInstance.cpp
  bolt/lib/Utils/CommandLineOpts.cpp


Index: bolt/lib/Utils/CommandLineOpts.cpp
===================================================================
--- bolt/lib/Utils/CommandLineOpts.cpp
+++ bolt/lib/Utils/CommandLineOpts.cpp
@@ -42,7 +42,7 @@
 
 cl::opt<unsigned> AlignText("align-text",
                             cl::desc("alignment of .text section"), cl::Hidden,
-                            cl::cat(BoltCategory));
+                            cl::init(64), cl::cat(BoltCategory));
 
 cl::opt<unsigned> AlignFunctions(
     "align-functions",
Index: bolt/lib/Rewrite/RewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/RewriteInstance.cpp
+++ bolt/lib/Rewrite/RewriteInstance.cpp
@@ -1778,9 +1778,6 @@
     opts::UseOldText = false;
   }
 
-  if (!opts::AlignText.getNumOccurrences())
-    opts::AlignText = BC->PageAlign;
-
   if (opts::AlignText < opts::AlignFunctions)
     opts::AlignText = (unsigned)opts::AlignFunctions;
 
Index: bolt/lib/Rewrite/MachORewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/MachORewriteInstance.cpp
+++ bolt/lib/Rewrite/MachORewriteInstance.cpp
@@ -606,10 +606,6 @@
 }
 
 void MachORewriteInstance::adjustCommandLineOptions() {
-//FIXME! Upstream change
-//  opts::CheckOverlappingElements = false;
-  if (!opts::AlignText.getNumOccurrences())
-    opts::AlignText = BC->PageAlign;
   if (opts::Instrument.getNumOccurrences())
     opts::ForcePatch = true;
   opts::JumpTables = JTS_MOVE;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137620.473916.patch
Type: text/x-patch
Size: 1509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221108/d874e8b5/attachment.bin>


More information about the llvm-commits mailing list