summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Instruction.cpp
diff options
context:
space:
mode:
authorDehao Chen <dehao@google.com>2017-03-23 23:26:00 +0000
committerDehao Chen <dehao@google.com>2017-03-23 23:26:00 +0000
commit722e94061baa662a0f41ede6fd0cf6d0dcf5932a (patch)
treee8de7b25f8207906b96af22fd15384142cde2639 /llvm/lib/IR/Instruction.cpp
parentdef79b21e4f45dec583beedf747c6a02c542164d (diff)
downloadbcm5719-llvm-722e94061baa662a0f41ede6fd0cf6d0dcf5932a.tar.gz
bcm5719-llvm-722e94061baa662a0f41ede6fd0cf6d0dcf5932a.zip
Set the prof weight correctly for call instructions in DeadArgumentElimination.
Summary: In DeadArgumentElimination, the call instructions will be replaced. We also need to set the prof weights so that function inlining can find the correct profile. Reviewers: eraman Reviewed By: eraman Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31143 llvm-svn: 298660
Diffstat (limited to 'llvm/lib/IR/Instruction.cpp')
-rw-r--r--llvm/lib/IR/Instruction.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index fc453d4f8d7..fc8a0566ab5 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -652,3 +652,12 @@ void Instruction::updateProfWeight(uint64_t S, uint64_t T) {
MDBuilder MDB(getContext());
setMetadata(LLVMContext::MD_prof, MDB.createBranchWeights(Weights));
}
+
+void Instruction::setProfWeight(uint64_t W) {
+ assert((isa<CallInst>(this) || isa<InvokeInst>(this)) &&
+ "Can only set weights for call and invoke instrucitons");
+ SmallVector<uint32_t, 1> Weights;
+ Weights.push_back(W);
+ MDBuilder MDB(getContext());
+ setMetadata(LLVMContext::MD_prof, MDB.createBranchWeights(Weights));
+}
OpenPOWER on IntegriCloud