diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2017-09-07 05:35:35 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2017-09-07 05:35:35 +0000 |
commit | 681fbb64a4cdaba874280bb23e41d2126c7c5766 (patch) | |
tree | a184914b63e3b0255bc80a29e8fcb9c0307a297a /llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | |
parent | 754e58407667361533f778ea195f3a98bafde3ec (diff) | |
download | llvm-681fbb64a4cdaba874280bb23e41d2126c7c5766.zip llvm-681fbb64a4cdaba874280bb23e41d2126c7c5766.tar.gz llvm-681fbb64a4cdaba874280bb23e41d2126c7c5766.tar.bz2 |
ModuleSummaryAnalysis: Correctly handle all function operand references.
The current code that handles personality functions when creating a
module summary does not correctly handle the case where a function's
personality function operand refers to the function indirectly
(e.g. via a bitcast). This patch handles such cases by treating
personality function references like any other reference, i.e. by
adding them to the function's reference list. This has the minor side
benefit of allowing personality functions to participate in early
dead stripping.
We do this by calling findRefEdges on the function itself. This way
we also end up handling other function operands (specifically prefix
data and prologue data) for free.
Differential Revision: https://reviews.llvm.org/D37553
llvm-svn: 312698
Diffstat (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp index 4950780..2b355de 100644 --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -215,9 +215,13 @@ computeFunctionSummary(ModuleSummaryIndex &Index, const Module &M, SetVector<FunctionSummary::ConstVCall> TypeTestAssumeConstVCalls, TypeCheckedLoadConstVCalls; ICallPromotionAnalysis ICallAnalysis; + SmallPtrSet<const User *, 8> Visited; + + // Add personality function, prefix data and prologue data to function's ref + // list. + findRefEdges(Index, &F, RefEdges, Visited); bool HasInlineAsmMaybeReferencingInternal = false; - SmallPtrSet<const User *, 8> Visited; for (const BasicBlock &BB : F) for (const Instruction &I : BB) { if (isa<DbgInfoIntrinsic>(I)) @@ -456,12 +460,6 @@ ModuleSummaryIndex llvm::buildModuleSummaryIndex( CantBePromoted); } - // Set live flag for all personality functions. That allows to - // preserve them during DCE. - for (const llvm::Function &F : M) - if (!F.isDeclaration() && F.hasPersonalityFn()) - setLiveRoot(Index, F.getPersonalityFn()->getName()); - // Compute summaries for all variables defined in module, and save in the // index. for (const GlobalVariable &G : M.globals()) { |