diff options
author | Volodymyr Sapsai <vsapsai@apple.com> | 2017-11-10 00:47:47 +0000 |
---|---|---|
committer | Volodymyr Sapsai <vsapsai@apple.com> | 2017-11-10 00:47:47 +0000 |
commit | a73960213eac65cbb099a52318035cf4539b7703 (patch) | |
tree | 8b656ede5a98dc9b870aab6a7d30fe0834e9e4ef /llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | |
parent | c183e2c33b0581390e678e74bcfc83b3a34f3350 (diff) | |
download | llvm-a73960213eac65cbb099a52318035cf4539b7703.zip llvm-a73960213eac65cbb099a52318035cf4539b7703.tar.gz llvm-a73960213eac65cbb099a52318035cf4539b7703.tar.bz2 |
[ThinLTO] Fix missing call graph edges for calls with bitcasts.
This change doesn't fix the root cause of the miscompile PR34966 as the root
cause is in the linker ld64. This change makes call graph more complete
allowing to have better module imports/exports.
rdar://problem/35344706
Reviewers: tejohnson
Reviewed By: tejohnson
Subscribers: mehdi_amini, inglorion, eraman, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D39356
llvm-svn: 317853
Diffstat (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp index 82db09c..8d1e7ee 100644 --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -243,6 +243,11 @@ computeFunctionSummary(ModuleSummaryIndex &Index, const Module &M, auto *CalledValue = CS.getCalledValue(); auto *CalledFunction = CS.getCalledFunction(); + if (CalledValue && !CalledFunction) { + CalledValue = CalledValue->stripPointerCastsNoFollowAliases(); + // Stripping pointer casts can reveal a called function. + CalledFunction = dyn_cast<Function>(CalledValue); + } // Check if this is an alias to a function. If so, get the // called aliasee for the checks below. if (auto *GA = dyn_cast<GlobalAlias>(CalledValue)) { @@ -275,9 +280,8 @@ computeFunctionSummary(ModuleSummaryIndex &Index, const Module &M, // Skip inline assembly calls. if (CI && CI->isInlineAsm()) continue; - // Skip direct calls. - if (!CS.getCalledValue() || isa<Constant>(CS.getCalledValue())) - continue; + assert(CalledValue && !isa<Constant>(CalledValue) && + "Expected indirect call"); uint32_t NumVals, NumCandidates; uint64_t TotalCount; |