summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2016-09-20 23:07:17 +0000
committerTeresa Johnson <tejohnson@google.com>2016-09-20 23:07:17 +0000
commit620c140a9b50b715296f2e1412834aac151bb440 (patch)
treeb511c96b0827282672ce5d3bc2ceb395cd20579a /llvm/test
parent92d1960e3b63c4c9ca7e7af3463b39c46864c792 (diff)
downloadbcm5719-llvm-620c140a9b50b715296f2e1412834aac151bb440.tar.gz
bcm5719-llvm-620c140a9b50b715296f2e1412834aac151bb440.zip
[ThinLTO] Always emit a summary when compiling in ThinLTO mode
Summary: Emit an empty summary section, instead of no summary section, when there are no global variables in the index. This ensures that LTO will treat these files as ThinLTO inputs, instead of as regular LTO inputs. In addition to not being what the user likely intended when compiling with -flto=thin, the current behavior is problematic for distributed build systems that expect to get ThinLTO index and imports files back for each input compiled with -flto=thin. Combining into a single regular LTO module also reduces the backend parallelism. And in the case where the index was suppressed due to uses in inline assembly, combining into a single LTO module could provoke renaming of duplicates that we were trying to prevent by suppressing the index. This change required a couple of fixes to handle the empty summary section. Reviewers: mehdi_amini Subscribers: mehdi_amini, llvm-commits, pcc Differential Revision: https://reviews.llvm.org/D24779 llvm-svn: 282037
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Bitcode/thinlto-empty-summary-section.ll7
-rw-r--r--llvm/test/ThinLTO/X86/Inputs/emit_imports.ll3
-rw-r--r--llvm/test/ThinLTO/X86/Inputs/empty.ll2
-rw-r--r--llvm/test/ThinLTO/X86/emit_imports.ll23
-rw-r--r--llvm/test/tools/gold/X86/Inputs/thinlto_empty.ll0
-rw-r--r--llvm/test/tools/gold/X86/thinlto_emit_imports.ll12
6 files changed, 43 insertions, 4 deletions
diff --git a/llvm/test/Bitcode/thinlto-empty-summary-section.ll b/llvm/test/Bitcode/thinlto-empty-summary-section.ll
new file mode 100644
index 00000000000..97086611ff4
--- /dev/null
+++ b/llvm/test/Bitcode/thinlto-empty-summary-section.ll
@@ -0,0 +1,7 @@
+; Ensure we get a summary block even when the file is empty.
+; RUN: opt -module-summary %s -o %t.o
+; RUN: llvm-bcanalyzer -dump %t.o | FileCheck %s
+
+; CHECK: <GLOBALVAL_SUMMARY_BLOCK
+; CHECK: <VERSION op0=
+; CHECK: </GLOBALVAL_SUMMARY_BLOCK>
diff --git a/llvm/test/ThinLTO/X86/Inputs/emit_imports.ll b/llvm/test/ThinLTO/X86/Inputs/emit_imports.ll
index 4e0840f3691..31c72ec4653 100644
--- a/llvm/test/ThinLTO/X86/Inputs/emit_imports.ll
+++ b/llvm/test/ThinLTO/X86/Inputs/emit_imports.ll
@@ -1,3 +1,6 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
define void @g() {
entry:
ret void
diff --git a/llvm/test/ThinLTO/X86/Inputs/empty.ll b/llvm/test/ThinLTO/X86/Inputs/empty.ll
new file mode 100644
index 00000000000..a3c99cdfe77
--- /dev/null
+++ b/llvm/test/ThinLTO/X86/Inputs/empty.ll
@@ -0,0 +1,2 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
diff --git a/llvm/test/ThinLTO/X86/emit_imports.ll b/llvm/test/ThinLTO/X86/emit_imports.ll
index a8215d50230..64ea02d857e 100644
--- a/llvm/test/ThinLTO/X86/emit_imports.ll
+++ b/llvm/test/ThinLTO/X86/emit_imports.ll
@@ -1,7 +1,11 @@
; RUN: opt -module-summary %s -o %t1.bc
; RUN: opt -module-summary %p/Inputs/emit_imports.ll -o %t2.bc
-; RUN: llvm-lto -thinlto-action=thinlink -o %t.index.bc %t1.bc %t2.bc
-; RUN: llvm-lto -thinlto-action=emitimports -thinlto-index %t.index.bc %t1.bc %t2.bc
+; Include a file with an empty module summary index, to ensure that the expected
+; output files are created regardless, for a distributed build system.
+; RUN: opt -module-summary %p/Inputs/empty.ll -o %t3.bc
+; RUN: rm -f %t3.bc.imports
+; RUN: llvm-lto -thinlto-action=thinlink -o %t.index.bc %t1.bc %t2.bc %t3.bc
+; RUN: llvm-lto -thinlto-action=emitimports -thinlto-index %t.index.bc %t1.bc %t2.bc %t3.bc
; The imports file for this module contains the bitcode file for
; Inputs/emit_imports.ll
@@ -12,9 +16,13 @@
; The imports file for Input/emit_imports.ll is empty as it does not import anything.
; RUN: cat %t2.bc.imports | count 0
+; The imports file for Input/empty.ll is empty but should exist.
+; RUN: cat %t3.bc.imports | count 0
+
; RUN: rm -f %t1.thinlto.bc %t1.bc.imports
; RUN: rm -f %t2.thinlto.bc %t2.bc.imports
-; RUN: llvm-lto2 %t1.bc %t2.bc -o %t.o \
+; RUN: rm -f %t3.bc.thinlto.bc %t3.bc.imports
+; RUN: llvm-lto2 %t1.bc %t2.bc %t3.bc -o %t.o -save-temps \
; RUN: -thinlto-distributed-indexes \
; RUN: -r=%t1.bc,g, \
; RUN: -r=%t1.bc,f,px \
@@ -26,6 +34,15 @@
; The imports file for Input/emit_imports.ll is empty as it does not import anything.
; RUN: cat %t2.bc.imports | count 0
+; The imports file for Input/empty.ll is empty but should exist.
+; RUN: cat %t3.bc.imports | count 0
+
+; The index file should be created even for the input with an empty summary.
+; RUN: ls %t3.bc.thinlto.bc
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
declare void @g(...)
define void @f() {
diff --git a/llvm/test/tools/gold/X86/Inputs/thinlto_empty.ll b/llvm/test/tools/gold/X86/Inputs/thinlto_empty.ll
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/llvm/test/tools/gold/X86/Inputs/thinlto_empty.ll
diff --git a/llvm/test/tools/gold/X86/thinlto_emit_imports.ll b/llvm/test/tools/gold/X86/thinlto_emit_imports.ll
index 845b691236c..4346ece7ce2 100644
--- a/llvm/test/tools/gold/X86/thinlto_emit_imports.ll
+++ b/llvm/test/tools/gold/X86/thinlto_emit_imports.ll
@@ -1,13 +1,17 @@
; Generate summary sections and test gold handling.
; RUN: opt -module-summary %s -o %t.o
; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
+; Include a file with an empty module summary index, to ensure that the expected
+; output files are created regardless, for a distributed build system.
+; RUN: opt -module-summary %p/Inputs/thinlto_empty.ll -o %t3.o
; Ensure gold generates imports files if requested for distributed backends.
+; RUN: rm -f %t3.o.imports %t3.o.thinlto.bc
; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
; RUN: --plugin-opt=thinlto \
; RUN: --plugin-opt=thinlto-index-only \
; RUN: --plugin-opt=thinlto-emit-imports-files \
-; RUN: -shared %t.o %t2.o -o %t3
+; RUN: -shared %t.o %t2.o %t3.o -o %t4
; The imports file for this module contains the bitcode file for
; Inputs/thinlto.ll
@@ -18,6 +22,12 @@
; The imports file for Input/thinlto.ll is empty as it does not import anything.
; RUN: cat %t2.o.imports | count 0
+; The imports file for Input/thinlto_empty.ll is empty but should exist.
+; RUN: cat %t3.o.imports | count 0
+
+; The index file should be created even for the input with an empty summary.
+; RUN: ls %t3.o.thinlto.bc
+
declare void @g(...)
define void @f() {
OpenPOWER on IntegriCloud