OSDN Git Service

BitcodeWriter: Remove redundant (and incorrect) check for whether to emit module...
authorPeter Collingbourne <peter@pcc.me.uk>
Fri, 24 Jun 2016 01:58:02 +0000 (01:58 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Fri, 24 Jun 2016 01:58:02 +0000 (01:58 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273638 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bitcode/Writer/BitcodeWriter.cpp
test/Bitcode/thinlto-summary-globalvar.ll [new file with mode: 0644]

index 20cbc2b..971d21e 100644 (file)
@@ -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/test/Bitcode/thinlto-summary-globalvar.ll b/test/Bitcode/thinlto-summary-globalvar.ll
new file mode 100644 (file)
index 0000000..56f9c07
--- /dev/null
@@ -0,0 +1,5 @@
+; RUN: opt -module-summary %s -o - | llvm-bcanalyzer -dump | FileCheck %s
+
+; CHECK: <GLOBALVAL_SUMMARY_BLOCK
+
+@a = global i32 0