[PATCH] D129178: [RISCV] Enable the GlobalMerge pass by default

Luís Marques via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 27 16:01:54 PDT 2022


luismarques added a comment.

In D129178#3669396 <https://reviews.llvm.org/D129178#3669396>, @craig.topper wrote:

> This patch seems to prevent GP linker relaxation on dhrystone. Presumably because the merged symbols are no longer in the .sbss section?

Yeah, probably because of that (or .sdata?). It seems the heuristic of being small is failing as a predictor of what you want to put in the relaxation range. I guess the actual metric you want to optimize for is the total number of symbol references that you can move from the general address range to the optimizable address range? Not the kind of thing you can do from a linker script... How big is the regression? For comparison, Embench `O3` and `Oz` have code size improvements of 3.35% and 2.92%, respectively (D129686 <https://reviews.llvm.org/D129686> doesn't seem to change that at all).



================
Comment at: llvm/lib/Target/RISCV/RISCVTargetMachine.cpp:213-217
+  if ((TM->getOptLevel() != CodeGenOpt::None &&
+       EnableGlobalMerge == cl::BOU_UNSET) ||
+      EnableGlobalMerge == cl::BOU_TRUE) {
+    bool OnlyOptimizeForSize = (TM->getOptLevel() < CodeGenOpt::Aggressive) &&
+                               (EnableGlobalMerge == cl::BOU_UNSET);
----------------
Please add a comment describing in prose when the option is enabled.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129178/new/

https://reviews.llvm.org/D129178



More information about the llvm-commits mailing list