[ThinLTO] Handle bitcode without function summary sections gracefully
authorTeresa Johnson <tejohnson@google.com>
Sat, 21 Nov 2015 21:55:48 +0000 (21:55 +0000)
committerTeresa Johnson <tejohnson@google.com>
Sat, 21 Nov 2015 21:55:48 +0000 (21:55 +0000)
commitf1f60632b06de61a15f7362002ef0fe3399a2d54
tree2d860ce7147892cf0c272c03ab3f9d3681da88d9
parentef8457f79e529990594d5c7feaf9e871fbc4b38e
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253796 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/IR/FunctionInfo.h
lib/Bitcode/Reader/BitcodeReader.cpp
lib/IR/FunctionInfo.cpp
test/Linker/funcimport.ll
test/tools/gold/X86/thinlto.ll
tools/gold/gold-plugin.cpp
tools/llvm-lto/llvm-lto.cpp