diff options
author | Zakk Chen <zakk.chen@sifive.com> | 2020-04-27 20:04:36 -0700 |
---|---|---|
committer | Zakk Chen <zakk.chen@sifive.com> | 2020-05-04 18:31:09 -0700 |
commit | ad5fad0ac56b78a692a052f2da397b4bc7fd6150 (patch) | |
tree | 443120a8bc6d8f5913652bc25720454021571c26 /llvm/lib/LTO/LTO.cpp | |
parent | 36183811fb5455ea18cf7d9cd03748076f20573b (diff) | |
download | llvm-ad5fad0ac56b78a692a052f2da397b4bc7fd6150.zip llvm-ad5fad0ac56b78a692a052f2da397b4bc7fd6150.tar.gz llvm-ad5fad0ac56b78a692a052f2da397b4bc7fd6150.tar.bz2 |
[LTO] Suppress emission of empty combined module by default
Summary:
That unless the user requested an output object (--lto-obj-path), the an
unused empty combined module is not emitted.
This changed is helpful for some target (ex. RISCV-V) which encoded the
ABI info in IR module flags (target-abi). Empty unused module has no ABI
info so the linker would get the linking error during merging
incompatible ABIs.
Reviewers: tejohnson, espindola, MaskRay
Subscribers: emaste, inglorion, arichardson, hiraditya, simoncook, MaskRay, steven_wu, dexonsmith, PkmX, dang, lenary, s.egerton, luismarques, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D78988
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index e9eb1d1..ab39a08 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -603,6 +603,7 @@ Error LTO::addModule(InputFile &Input, unsigned ModI, if (LTOInfo->IsThinLTO) return addThinLTO(BM, ModSyms, ResI, ResE); + RegularLTO.EmptyCombinedModule = false; Expected<RegularLTOState::AddedModule> ModOrErr = addRegularLTO(BM, ModSyms, ResI, ResE); if (!ModOrErr) @@ -1026,10 +1027,13 @@ Error LTO::runRegularLTO(AddStreamFn AddStream) { !Conf.PostInternalizeModuleHook(0, *RegularLTO.CombinedModule)) return Error::success(); } - if (Error Err = - backend(Conf, AddStream, RegularLTO.ParallelCodeGenParallelismLevel, - std::move(RegularLTO.CombinedModule), ThinLTO.CombinedIndex)) - return Err; + + if (!RegularLTO.EmptyCombinedModule || Conf.AlwaysEmitRegularLTOObj) { + if (Error Err = backend( + Conf, AddStream, RegularLTO.ParallelCodeGenParallelismLevel, + std::move(RegularLTO.CombinedModule), ThinLTO.CombinedIndex)) + return Err; + } return finalizeOptimizationRemarks(std::move(*DiagFileOrErr)); } |