Index: llvm/test/Assembler/summary-flags2.ll =================================================================== --- /dev/null +++ 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 Index: llvm/tools/llvm-as/llvm-as.cpp =================================================================== --- llvm/tools/llvm-as/llvm-as.cpp +++ llvm/tools/llvm-as/llvm-as.cpp @@ -92,7 +92,7 @@ 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()) + 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