[llvm] 8f8756d - [Assembler] Allow assembling empty index with non-zero flags

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 26 05:37:23 PST 2020


Author: evgeny
Date: 2020-02-26T16:34:11+03:00
New Revision: 8f8756d465e4743c7cffebc26de682e864c94d57

URL: https://github.com/llvm/llvm-project/commit/8f8756d465e4743c7cffebc26de682e864c94d57
DIFF: https://github.com/llvm/llvm-project/commit/8f8756d465e4743c7cffebc26de682e864c94d57.diff

LOG: [Assembler] Allow assembling empty index with non-zero flags

Differential revision: https://reviews.llvm.org/D74778

Added: 
    llvm/test/Assembler/summary-flags2.ll

Modified: 
    llvm/tools/llvm-as/llvm-as.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/Assembler/summary-flags2.ll b/llvm/test/Assembler/summary-flags2.ll
new file mode 100644
index 000000000000..8abca0ea9e5b
--- /dev/null
+++ b/llvm/test/Assembler/summary-flags2.ll
@@ -0,0 +1,8 @@
+; Check that we can assemble/disassemble empty index with non-trivial flags
+; RUN: llvm-as %s -o - | llvm-dis -o - | FileCheck %s
+
+; ModuleID = 'index.bc'
+source_filename = "index.bc"
+
+^0 = flags: 2
+; CHECK: ^0 = flags: 2

diff  --git a/llvm/tools/llvm-as/llvm-as.cpp b/llvm/tools/llvm-as/llvm-as.cpp
index c9f50e38fc61..0f6de69c10dd 100644
--- a/llvm/tools/llvm-as/llvm-as.cpp
+++ b/llvm/tools/llvm-as/llvm-as.cpp
@@ -90,9 +90,11 @@ static void WriteOutputFile(const Module *M, const ModuleSummaryIndex *Index) {
 
   if (Force || !CheckBitcodeOutputToConsole(Out->os(), true)) {
     const ModuleSummaryIndex *IndexToWrite = nullptr;
-    // Don't attempt to write a summary index unless it contains any entries.
-    // Otherwise we get an empty summary section.
-    if (Index && Index->begin() != Index->end())
+    // Don't attempt to write a summary index unless it contains any entries or
+    // has non-zero flags. The latter is used to assemble dummy index files for
+    // skipping modules by distributed ThinLTO backends. Otherwise we get an empty
+    // summary section.
+    if (Index && (Index->begin() != Index->end() || Index->getFlags()))
       IndexToWrite = Index;
     if (!IndexToWrite || (M && (!M->empty() || !M->global_empty())))
       // If we have a non-empty Module, then we write the Module plus


        


More information about the llvm-commits mailing list