[PATCH] D36850: [ThinLTO] Add norecurse function attribute propagation
Di Mo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 8 00:01:00 PDT 2021
modimo updated this revision to Diff 350509.
modimo added a comment.
@tejohnson
I was looking at the initial implementation and looking at purely the front entry of the SummaryList seems suspect given:
1. There could be multiple entries from linkonce_odr
2. The first entry isn't guaranteed to be a FunctionSummary
Looking around I saw that SafeStack (https://github.com/llvm/llvm-project/commit/47552a614a8c95e1817d83755a4a6a2508da7f8a) took these into account with `findCalleeFunctionSummary` which to me makes more sense as an implementation. For function attribute propagation, we can also handle linkonce_odr naively by doing a conservative union of the attributes.
More aggressively, propagating based off of the prevailing definition would be more powerful/simpler but there's some nuance shown in the linkonce_functionattrs_comdat.ll test added. If we propagated the prevailing definition `g` would be marked as norecurse. However, if the local copy of `f` is inlined into `g` that attribute would be incorrect and AFAICT currently thinLTO doesn't enforce using the prevailing definition everywhere presumably because it will break code that relies on using the local copy.
I'll definitely measure the compile time cost of this. Wanted to get some feedback on if this path makes sense first.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D36850/new/
https://reviews.llvm.org/D36850
Files:
clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
clang/test/CodeGen/thinlto-distributed-cfi.ll
llvm/include/llvm/IR/ModuleSummaryIndex.h
llvm/include/llvm/LTO/LTO.h
llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
llvm/lib/LTO/LTO.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/test/ThinLTO/X86/Inputs/functionattr-prop.ll
llvm/test/ThinLTO/X86/Inputs/linkonce_functionattrs_comdat.ll
llvm/test/ThinLTO/X86/deadstrip.ll
llvm/test/ThinLTO/X86/function_entry_count.ll
llvm/test/ThinLTO/X86/functionattr-prop.ll
llvm/test/ThinLTO/X86/linkonce_functionattrs_comdat.ll
llvm/test/ThinLTO/X86/linkonce_resolution_comdat.ll
llvm/test/ThinLTO/X86/not-internalized.ll
llvm/test/ThinLTO/X86/weak_externals.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36850.350509.patch
Type: text/x-patch
Size: 21243 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210608/4d64cf83/attachment.bin>
More information about the llvm-commits
mailing list