[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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317853 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Volodymyr Sapsai
2017-11-10 00:47:47 +00:00
parent 37ff1dce27
commit 8887214dfa
2 changed files with 38 additions and 3 deletions
+7 -3
View File
@@ -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;