[llvm] r291302 - [ThinLTO] Optionally ignore empty index file
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 6 15:37:17 PST 2017
Author: tejohnson
Date: Fri Jan 6 17:37:17 2017
New Revision: 291302
URL: http://llvm.org/viewvc/llvm-project?rev=291302&view=rev
Log:
[ThinLTO] Optionally ignore empty index file
Summary:
In order to simplify distributed build system integration, where actions
may be scheduled before the Thin Link which determines the list of
objects selected by the linker. The gold plugin currently will emit
0-sized index files for objects not selected by the link, to enable
checking for expected output files by the build system. If the build
system then schedules a backend action for these bitcode files, we want
to be able to fall back to normal compilation instead of failing.
This is the LLVM side support for optionally enabling fallback
instead of issuing an error. Return a null CombinedIndex from
llvm::getModuleSummaryIndexForFile under the option when the file
is empty. Clang can then ignore the index when it is null.
Clang patch is D28362.
Reviewers: mehdi_amini
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D28410
Modified:
llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp
Modified: llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp?rev=291302&r1=291301&r2=291302&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp Fri Jan 6 17:37:17 2017
@@ -22,6 +22,12 @@
using namespace llvm;
using namespace object;
+static llvm::cl::opt<bool> IgnoreEmptyThinLTOIndexFile(
+ "ignore-empty-index-file", llvm::cl::ZeroOrMore,
+ llvm::cl::desc(
+ "Ignore an empty index file and perform non-ThinLTO compilation"),
+ llvm::cl::init(false));
+
ModuleSummaryIndexObjectFile::ModuleSummaryIndexObjectFile(
MemoryBufferRef Object, std::unique_ptr<ModuleSummaryIndex> I)
: SymbolicFile(Binary::ID_ModuleSummaryIndex, Object), Index(std::move(I)) {
@@ -97,6 +103,8 @@ llvm::getModuleSummaryIndexForFile(Strin
if (EC)
return errorCodeToError(EC);
MemoryBufferRef BufferRef = (FileOrErr.get())->getMemBufferRef();
+ if (IgnoreEmptyThinLTOIndexFile && !BufferRef.getBufferSize())
+ return nullptr;
Expected<std::unique_ptr<object::ModuleSummaryIndexObjectFile>> ObjOrErr =
object::ModuleSummaryIndexObjectFile::create(BufferRef);
if (!ObjOrErr)
More information about the llvm-commits
mailing list