summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/SampleProfile.cpp
diff options
context:
space:
mode:
authorDehao Chen <dehao@google.com>2017-09-19 18:26:54 +0000
committerDehao Chen <dehao@google.com>2017-09-19 18:26:54 +0000
commitb6e60c8b80704e948cf049569145ddf8497d7e05 (patch)
tree3d75dfb13efa0af1be8c57b31d5da83c50c98a79 /llvm/lib/Transforms/IPO/SampleProfile.cpp
parent26fa1bf4da3cbae98251ebd2db2dcee37b89120c (diff)
downloadbcm5719-llvm-b6e60c8b80704e948cf049569145ddf8497d7e05.tar.gz
bcm5719-llvm-b6e60c8b80704e948cf049569145ddf8497d7e05.zip
Handle profile mismatch correctly for SamplePGO.
Summary: Fix the bug when promoted call return type mismatches with the promoted function, we should not try to inline it. Otherwise it may lead to compiler crash. Reviewers: davidxl, tejohnson, eraman Reviewed By: tejohnson Subscribers: llvm-commits, sanjoy Differential Revision: https://reviews.llvm.org/D38018 llvm-svn: 313658
Diffstat (limited to 'llvm/lib/Transforms/IPO/SampleProfile.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/SampleProfile.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index ac20d2a520d..039fed0360f 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -720,7 +720,7 @@ bool SampleProfileLoader::inlineHotFunctions(
continue;
Instruction *DI = I;
if (!CalledFunction && !PromotedInsns.count(I) &&
- CallSite(I).isIndirectCall())
+ CallSite(I).isIndirectCall()) {
for (const auto *FS : findIndirectCallFunctionSamples(*I)) {
auto CalleeFunctionName = FS->getName();
// If it is a recursive call, we do not inline it as it could bloat
@@ -751,12 +751,17 @@ bool SampleProfileLoader::inlineHotFunctions(
continue;
}
}
+ // If there is profile mismatch, we should not attempt to inline DI.
+ if (!isa<CallInst>(DI) && !isa<InvokeInst>(DI))
+ continue;
+ }
if (!CalledFunction || !CalledFunction->getSubprogram()) {
findCalleeFunctionSamples(*I)->findImportedFunctions(
ImportGUIDs, F.getParent(),
Samples->getTotalSamples() * SampleProfileHotThreshold / 100);
continue;
}
+ assert(isa<CallInst>(DI) || isa<InvokeInst>(DI));
CallSite CS(DI);
DebugLoc DLoc = I->getDebugLoc();
BasicBlock *BB = I->getParent();
OpenPOWER on IntegriCloud