[PATCH] D95541: Support Os or Oz during LTO
Jin Lin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 23 09:15:59 PDT 2021
jinlin updated this revision to Diff 340068.
jinlin edited the summary of this revision.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95541/new/
https://reviews.llvm.org/D95541
Files:
llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
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 @@
CG->setAttr(attrs);
}
- 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);
}
@@ -502,8 +506,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
@@ -211,6 +211,10 @@
}
void LTOCodeGenerator::setOptLevel(unsigned Level) {
+ if (Level > 3) {
+ SizeLevel = Level - 3;
+ Level = 2;
+ }
OptLevel = Level;
switch (OptLevel) {
case 0:
@@ -578,7 +582,7 @@
PassManagerBuilder PMB;
PMB.LoopVectorize = true;
PMB.SLPVectorize = true;
- PMB.Inliner = createFunctionInliningPass();
+ PMB.Inliner = createFunctionInliningPass(OptLevel, SizeLevel, false);
PMB.LibraryInfo = new TargetLibraryInfoImpl(TargetTriple);
if (Freestanding)
PMB.LibraryInfo->disableAllFunctions();
Index: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
===================================================================
--- llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
+++ llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
@@ -230,6 +230,7 @@
const Target *MArch = nullptr;
std::string TripleStr;
unsigned OptLevel = 2;
+ unsigned SizeLevel = 0;
lto_diagnostic_handler_t DiagHandler = nullptr;
void *DiagContext = nullptr;
bool ShouldInternalize = EnableLTOInternalization;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95541.340068.patch
Type: text/x-patch
Size: 2398 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210423/9fbe49fb/attachment.bin>
More information about the llvm-commits
mailing list