[llvm] r279416 - [LTO] Add a "CodeGenOnly" option. Allows the client to skip the optimizer.
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 21 23:25:42 PDT 2016
Author: mehdi_amini
Date: Mon Aug 22 01:25:41 2016
New Revision: 279416
URL: http://llvm.org/viewvc/llvm-project?rev=279416&view=rev
Log:
[LTO] Add a "CodeGenOnly" option. Allows the client to skip the optimizer.
Summary: Slowly getting on par with libLTO
Reviewers: tejohnson
Subscribers: llvm-commits, mehdi_amini
Differential Revision: https://reviews.llvm.org/D23615
Modified:
llvm/trunk/include/llvm/LTO/Config.h
llvm/trunk/lib/LTO/LTO.cpp
llvm/trunk/lib/LTO/LTOBackend.cpp
Modified: llvm/trunk/include/llvm/LTO/Config.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LTO/Config.h?rev=279416&r1=279415&r2=279416&view=diff
==============================================================================
--- llvm/trunk/include/llvm/LTO/Config.h (original)
+++ llvm/trunk/include/llvm/LTO/Config.h Mon Aug 22 01:25:41 2016
@@ -52,6 +52,9 @@ struct Config {
unsigned OptLevel = 2;
bool DisableVerify = false;
+ /// Disable entirely the optimizer, including importing for ThinLTO
+ bool CodeGenOnly = false;
+
/// Setting this field will replace target triples in input files with this
/// triple.
std::string OverrideTriple;
Modified: llvm/trunk/lib/LTO/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTO.cpp?rev=279416&r1=279415&r2=279416&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTO.cpp (original)
+++ llvm/trunk/lib/LTO/LTO.cpp Mon Aug 22 01:25:41 2016
@@ -365,27 +365,29 @@ Error LTO::runRegularLTO(AddOutputFn Add
!Conf.PreOptModuleHook(0, *RegularLTO.CombinedModule))
return Error();
- for (const auto &R : GlobalResolutions) {
- if (R.second.IRName.empty())
- continue;
- if (R.second.Partition != 0 &&
- R.second.Partition != GlobalResolution::External)
- continue;
+ if (!Conf.CodeGenOnly) {
+ for (const auto &R : GlobalResolutions) {
+ if (R.second.IRName.empty())
+ continue;
+ if (R.second.Partition != 0 &&
+ R.second.Partition != GlobalResolution::External)
+ continue;
- GlobalValue *GV = RegularLTO.CombinedModule->getNamedValue(R.second.IRName);
- // Ignore symbols defined in other partitions.
- if (!GV || GV->hasLocalLinkage())
- continue;
- GV->setUnnamedAddr(R.second.UnnamedAddr ? GlobalValue::UnnamedAddr::Global
- : GlobalValue::UnnamedAddr::None);
- if (R.second.Partition == 0)
- GV->setLinkage(GlobalValue::InternalLinkage);
- }
-
- if (Conf.PostInternalizeModuleHook &&
- !Conf.PostInternalizeModuleHook(0, *RegularLTO.CombinedModule))
- return Error();
+ GlobalValue *GV =
+ RegularLTO.CombinedModule->getNamedValue(R.second.IRName);
+ // Ignore symbols defined in other partitions.
+ if (!GV || GV->hasLocalLinkage())
+ continue;
+ GV->setUnnamedAddr(R.second.UnnamedAddr ? GlobalValue::UnnamedAddr::Global
+ : GlobalValue::UnnamedAddr::None);
+ if (R.second.Partition == 0)
+ GV->setLinkage(GlobalValue::InternalLinkage);
+ }
+ if (Conf.PostInternalizeModuleHook &&
+ !Conf.PostInternalizeModuleHook(0, *RegularLTO.CombinedModule))
+ return Error();
+ }
return backend(Conf, AddOutput, RegularLTO.ParallelCodeGenParallelismLevel,
std::move(RegularLTO.CombinedModule));
}
Modified: llvm/trunk/lib/LTO/LTOBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOBackend.cpp?rev=279416&r1=279415&r2=279416&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOBackend.cpp (original)
+++ llvm/trunk/lib/LTO/LTOBackend.cpp Mon Aug 22 01:25:41 2016
@@ -224,8 +224,9 @@ Error lto::backend(Config &C, AddOutputF
std::unique_ptr<TargetMachine> TM =
createTargetMachine(C, M->getTargetTriple(), *TOrErr);
- if (!opt(C, TM.get(), 0, *M, /*IsThinLto=*/false))
- return Error();
+ if (!C.CodeGenOnly)
+ if (!opt(C, TM.get(), 0, *M, /*IsThinLto=*/false))
+ return Error();
if (ParallelCodeGenParallelismLevel == 1)
codegen(C, TM.get(), AddOutput, 0, *M);
@@ -247,6 +248,11 @@ Error lto::thinBackend(Config &Conf, uns
std::unique_ptr<TargetMachine> TM =
createTargetMachine(Conf, Mod.getTargetTriple(), *TOrErr);
+ if (Conf.CodeGenOnly) {
+ codegen(Conf, TM.get(), AddOutput, Task, Mod);
+ return Error();
+ }
+
if (Conf.PreOptModuleHook && !Conf.PreOptModuleHook(Task, Mod))
return Error();
More information about the llvm-commits
mailing list