[PATCH] D95541: Support Os or Oz during LTO
Jin Lin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 23 10:05:36 PDT 2021
jinlin updated this revision to Diff 340096.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95541/new/
https://reviews.llvm.org/D95541
Files:
llvm/include/llvm/LTO/Config.h
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/LTO/LTOCodeGenerator.cpp
llvm/tools/lto/lto.cpp
Index: llvm/tools/lto/lto.cpp
===================================================================
--- llvm/tools/lto/lto.cpp
+++ llvm/tools/lto/lto.cpp
@@ -152,8 +152,12 @@
LTOCodeGenerator *CG = unwrap(cg);
CG->setAttrs(codegen::getMAttrs());
- if (OptLevel < '0' || OptLevel > '3')
- report_fatal_error("Optimization level must be between 0 and 3");
+ if (OptLevel == 's')
+ OptLevel = '4';
+ else if (OptLevel == 'z')
+ OptLevel = '5';
+ if (OptLevel < '0' || OptLevel > '5')
+ report_fatal_error("Optimization level must be between 0 and 3 or Os or Oz");
CG->setOptLevel(OptLevel - '0');
CG->setFreestanding(EnableFreestanding);
CG->setDisableVerify(DisableVerify);
@@ -521,8 +525,12 @@
CodeGen->setFreestanding(EnableFreestanding);
if (OptLevel.getNumOccurrences()) {
- if (OptLevel < '0' || OptLevel > '3')
- report_fatal_error("Optimization level must be between 0 and 3");
+ if (OptLevel == 's')
+ OptLevel = '4';
+ else if (OptLevel == 'z')
+ OptLevel = '5';
+ if (OptLevel < '0' || OptLevel > '5')
+ report_fatal_error("Optimization level must be between 0 and 3 or Os or Oz");
CodeGen->setOptLevel(OptLevel - '0');
switch (OptLevel) {
case '0':
Index: llvm/lib/LTO/LTOCodeGenerator.cpp
===================================================================
--- llvm/lib/LTO/LTOCodeGenerator.cpp
+++ llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -185,6 +185,10 @@
}
void LTOCodeGenerator::setOptLevel(unsigned Level) {
+ if (Level > 3) {
+ Config.SizeLevel = Level - 3;
+ Level = 2;
+ }
Config.OptLevel = Level;
Config.PTO.LoopVectorization = Config.OptLevel > 1;
Config.PTO.SLPVectorization = Config.OptLevel > 1;
Index: llvm/lib/LTO/LTOBackend.cpp
===================================================================
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -311,7 +311,7 @@
PMB.LibraryInfo = new TargetLibraryInfoImpl(Triple(TM->getTargetTriple()));
if (Conf.Freestanding)
PMB.LibraryInfo->disableAllFunctions();
- PMB.Inliner = createFunctionInliningPass();
+ PMB.Inliner = createFunctionInliningPass(Conf.OptLevel, Conf.SizeLevel, false);
PMB.ExportSummary = ExportSummary;
PMB.ImportSummary = ImportSummary;
// Unconditionally verify input since it is not verified before this
Index: llvm/include/llvm/LTO/Config.h
===================================================================
--- llvm/include/llvm/LTO/Config.h
+++ llvm/include/llvm/LTO/Config.h
@@ -55,6 +55,7 @@
CodeGenOpt::Level CGOptLevel = CodeGenOpt::Default;
CodeGenFileType CGFileType = CGFT_ObjectFile;
unsigned OptLevel = 2;
+ unsigned SizeLevel = 0;
bool DisableVerify = false;
/// Use the new pass manager
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95541.340096.patch
Type: text/x-patch
Size: 2753 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210423/e58e0e5f/attachment.bin>
More information about the llvm-commits
mailing list