From 4a9dd70213f5359b5dc5b3772f81a0b1c40ee55b Mon Sep 17 00:00:00 2001 From: Dehao Chen Date: Mon, 6 Feb 2017 23:33:15 +0000 Subject: Fix the samplepgo indirect call promotion bug: we should not promote a direct call. Summary: Checking CS.getCalledFunction() == nullptr does not necessary indicate indirect call. We also need to check if CS.getCalledValue() is not a constant. Reviewers: davidxl Reviewed By: davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29570 llvm-svn: 294260 --- llvm/lib/Transforms/IPO/SampleProfile.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/lib') diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp index 87015272b96..d6678279355 100644 --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -634,7 +634,8 @@ bool SampleProfileLoader::inlineHotFunctions(Function &F) { InlineFunctionInfo IFI(nullptr, ACT ? &GetAssumptionCache : nullptr); Function *CalledFunction = CallSite(I).getCalledFunction(); Instruction *DI = I; - if (!CalledFunction && !PromotedInsns.count(I)) { + if (!CalledFunction && !PromotedInsns.count(I) && + CallSite(I).isIndirectCall()) { auto CalleeFunctionName = findCalleeFunctionSamples(*I)->getName(); const char *Reason = "Callee function not available"; CalledFunction = F.getParent()->getFunction(CalleeFunctionName); -- cgit v1.2.3