diff options
author | Dehao Chen <dehao@google.com> | 2017-03-31 15:59:52 +0000 |
---|---|---|
committer | Dehao Chen <dehao@google.com> | 2017-03-31 15:59:52 +0000 |
commit | fed890ea3a948170438a963b60acc158858a7d98 (patch) | |
tree | 55b531fd6959f1a265197845ae2fa36fa9bad240 /llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | |
parent | f1a30f18008de1a71e2a82528c3e8689fef070bb (diff) | |
download | bcm5719-llvm-fed890ea3a948170438a963b60acc158858a7d98.tar.gz bcm5719-llvm-fed890ea3a948170438a963b60acc158858a7d98.zip |
Fix the InstCombine to reserve the VP metadata and sets correct call count.
Summary: Currently the VP metadata was dropped when InstCombine converts a call to direct call. This patch converts the VP metadata to branch_weights so that its hotness is recorded.
Reviewers: eraman, davidxl
Reviewed By: davidxl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D31344
llvm-svn: 299228
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index f3fc1e2d631..71ca14dee58 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -4143,6 +4143,12 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { CallInst *CI = cast<CallInst>(Caller); NC = Builder->CreateCall(Callee, Args, OpBundles); NC->takeName(CI); + // Preserve the weight metadata for the new call instruction. The metadata + // is used by SamplePGO to check callsite's hotness. + uint64_t W; + if (CI->extractProfTotalWeight(W)) + NC->setProfWeight(W); + cast<CallInst>(NC)->setTailCallKind(CI->getTailCallKind()); cast<CallInst>(NC)->setCallingConv(CI->getCallingConv()); cast<CallInst>(NC)->setAttributes(NewCallerPAL); |