summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2015-11-21 21:55:48 +0000
committerTeresa Johnson <tejohnson@google.com>2015-11-21 21:55:48 +0000
commit6290dbc0f7f71dbf9e5408a1b4222cbbfba43bdb (patch)
tree08a37c7cc3b671a0a5a0cd2533adc14c7110f426 /llvm/test
parent2829c1cf7b21d003e30a214d2414cbdbd40417d1 (diff)
downloadbcm5719-llvm-6290dbc0f7f71dbf9e5408a1b4222cbbfba43bdb.tar.gz
bcm5719-llvm-6290dbc0f7f71dbf9e5408a1b4222cbbfba43bdb.zip
[ThinLTO] Handle bitcode without function summary sections gracefully
Summary: Several fixes to the handling of bitcode files without function summary sections so that they are skipped during ThinLTO processing in llvm-lto and the gold plugin when appropriate instead of aborting. 1 Don't assert when trying to add a FunctionInfo that doesn't have a summary attached. 2 Skip FunctionInfo structures that don't have attached function summary sections when trying to create the combined function summary. 3 In both llvm-lto and gold-plugin, check whether a bitcode file has a function summary section before trying to parse the index, and skip the bitcode file if it does not. 4 Fix hasFunctionSummaryInMemBuffer in BitcodeReader, which had a bug where we returned to early while looking for the summary section. Also added llvm-lto and gold-plugin based tests for cases where we don't have function summaries in the bitcode file. I verified that either the first couple fixes described above are enough to avoid the crashes, or fixes 1,3,4. But have combined them all here for added robustness. Reviewers: joker.eph Subscribers: llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D14903 llvm-svn: 253796
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Linker/funcimport.ll7
-rw-r--r--llvm/test/tools/gold/X86/thinlto.ll8
2 files changed, 15 insertions, 0 deletions
diff --git a/llvm/test/Linker/funcimport.ll b/llvm/test/Linker/funcimport.ll
index dad9b95bb9f..d6aa0502f26 100644
--- a/llvm/test/Linker/funcimport.ll
+++ b/llvm/test/Linker/funcimport.ll
@@ -1,3 +1,10 @@
+; First ensure that the ThinLTO handling in llvm-link and llvm-lto handles
+; bitcode without function summary sections gracefully.
+; RUN: llvm-as %s -o %t.bc
+; RUN: llvm-as %p/Inputs/funcimport.ll -o %t2.bc
+; RUN: llvm-link %t.bc -functionindex=%t.bc -S
+; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
+
; Do setup work for all below tests: generate bitcode and combined index
; RUN: llvm-as -function-summary %s -o %t.bc
; RUN: llvm-as -function-summary %p/Inputs/funcimport.ll -o %t2.bc
diff --git a/llvm/test/tools/gold/X86/thinlto.ll b/llvm/test/tools/gold/X86/thinlto.ll
index b24e4af80bf..97def3d7a14 100644
--- a/llvm/test/tools/gold/X86/thinlto.ll
+++ b/llvm/test/tools/gold/X86/thinlto.ll
@@ -1,3 +1,11 @@
+; First ensure that the ThinLTO handling in the gold plugin handles
+; bitcode without function summary sections gracefully.
+; RUN: llvm-as %s -o %t.o
+; RUN: llvm-as %p/Inputs/thinlto.ll -o %t2.o
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
+; RUN: --plugin-opt=thinlto \
+; RUN: -shared %t.o %t2.o -o %t3
+
; RUN: llvm-as -function-summary %s -o %t.o
; RUN: llvm-as -function-summary %p/Inputs/thinlto.ll -o %t2.o
OpenPOWER on IntegriCloud