diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 20cbc2bf4b619..971d21ecc2f56 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -3271,9 +3271,6 @@ static const uint64_t INDEX_VERSION = 1; /// Emit the per-module summary section alongside the rest of /// the module's bitcode. void ModuleBitcodeWriter::writePerModuleGlobalValueSummary() { - if (M.empty()) - return; - if (Index->begin() == Index->end()) return; diff --git a/llvm/test/Bitcode/thinlto-summary-globalvar.ll b/llvm/test/Bitcode/thinlto-summary-globalvar.ll new file mode 100644 index 0000000000000..56f9c0788751b --- /dev/null +++ b/llvm/test/Bitcode/thinlto-summary-globalvar.ll @@ -0,0 +1,5 @@ +; RUN: opt -module-summary %s -o - | llvm-bcanalyzer -dump | FileCheck %s + +; CHECK: