[ThinLTO] Add noRecurse and noUnwind thinlink function attribute propagation
authormodimo <modimo@fb.com>
Mon, 27 Sep 2021 19:24:28 +0000 (12:24 -0700)
committermodimo <modimo@fb.com>
Mon, 27 Sep 2021 19:28:07 +0000 (12:28 -0700)
commit20faf789199d31a40c7f1a359361980c65067aab
tree2979f644ca4617bf88503deb7242ee105c19337a
parentd20d0e145d2fce3a39bd6a76df47455134167cdd
[ThinLTO] Add noRecurse and noUnwind thinlink function attribute propagation

Thinlink provides an opportunity to propagate function attributes across modules, enabling additional propagation opportunities.

This change propagates (currently default off, turn on with `disable-thinlto-funcattrs=1`) noRecurse and noUnwind based off of function summaries of the prevailing functions in bottom-up call-graph order. Testing on clang self-build:
1. There's a 35-40% increase in noUnwind functions due to the additional propagation opportunities.
2. Throughput is measured at 10-15% increase in thinlink time which itself is 1.5% of E2E link time.

Implementation-wise this adds the following summary function attributes:
1. noUnwind: function is noUnwind
2. mayThrow: function contains a non-call instruction that `Instruction::mayThrow` returns true on (e.g. windows SEH instructions)
3. hasUnknownCall: function contains calls that don't make it into the summary call-graph thus should not be propagated from (e.g. indirect for now, could add no-opt functions as well)

Testing:
Clang self-build passes and 2nd stage build passes check-all
ninja check-all with newly added tests passing

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D36850
36 files changed:
clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
clang/test/CodeGen/thinlto-distributed-cfi.ll
clang/test/CodeGen/thinlto-funcattr-prop.ll [new file with mode: 0644]
llvm/include/llvm/AsmParser/LLToken.h
llvm/include/llvm/IR/GlobalValue.h
llvm/include/llvm/IR/ModuleSummaryIndex.h
llvm/include/llvm/LTO/LTO.h
llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
llvm/include/llvm/Transforms/IPO/FunctionImport.h
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/ModuleSummaryIndex.cpp
llvm/lib/LTO/LTO.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/lib/Transforms/IPO/FunctionImport.cpp
llvm/test/Assembler/thinlto-summary.ll
llvm/test/Bitcode/thinlto-function-summary-refgraph.ll
llvm/test/Bitcode/thinlto-type-vcalls.ll
llvm/test/ThinLTO/X86/deadstrip.ll
llvm/test/ThinLTO/X86/dot-dumper.ll
llvm/test/ThinLTO/X86/dot-dumper2.ll
llvm/test/ThinLTO/X86/funcattrs-prop-exported-internal.ll [new file with mode: 0644]
llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll [new file with mode: 0644]
llvm/test/ThinLTO/X86/funcattrs-prop-undefined.ll [new file with mode: 0644]
llvm/test/ThinLTO/X86/funcattrs-prop-unknown.ll [new file with mode: 0644]
llvm/test/ThinLTO/X86/funcattrs-prop-weak.ll [new file with mode: 0644]
llvm/test/ThinLTO/X86/funcattrs-prop.ll [new file with mode: 0644]
llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll
llvm/test/ThinLTO/X86/function_entry_count.ll
llvm/test/ThinLTO/X86/linkonce_resolution_comdat.ll