From b19924a425edc9ff045fd20c794a6ec9917ba824 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 24 Jun 2016 01:58:02 +0000 Subject: [PATCH] BitcodeWriter: Remove redundant (and incorrect) check for whether to emit module summary. The function name Module::empty() is slightly misleading in that it only tests for the presence of functions in the module. However we still want to emit the module summary if the module contains only global variables or aliases. The presence of such entities can be determined simply by checking the summary directly, as we are doing below. Differential Revision: http://reviews.llvm.org/D21669 llvm-svn: 273638 --- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 3 --- llvm/test/Bitcode/thinlto-summary-globalvar.ll | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 llvm/test/Bitcode/thinlto-summary-globalvar.ll 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: