summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-04-25 23:15:16 +0000
committerSanjay Patel <spatel@rotateright.com>2016-04-25 23:15:16 +0000
commit82059090d361c98d836b603b83535208f5e571b9 (patch)
tree9f73f07aef2eca0fe57aa3d12a3fd70d47c11594 /llvm/lib/IR
parented737d7881ebdadf7d66a03a8502e3899f162ade (diff)
downloadbcm5719-llvm-82059090d361c98d836b603b83535208f5e571b9.tar.gz
bcm5719-llvm-82059090d361c98d836b603b83535208f5e571b9.zip
Add check for "branch_weights" with prof metadata
While we're here, fix the comment and variable names to make it clear that these are raw weights, not percentages. llvm-svn: 267491
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/Instructions.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 0d5bd9e9429..d66ec8f8d45 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -1120,20 +1120,24 @@ void BranchInst::swapSuccessors() {
MDNode::get(ProfileData->getContext(), Ops));
}
-bool BranchInst::extractProfMetadata(uint64_t &ProbTrue, uint64_t &ProbFalse) {
+bool BranchInst::extractProfMetadata(uint64_t &TrueVal, uint64_t &FalseVal) {
assert(isConditional() &&
"Looking for probabilities on unconditional branch?");
auto *ProfileData = getMetadata(LLVMContext::MD_prof);
if (!ProfileData || ProfileData->getNumOperands() != 3)
return false;
+ auto *ProfDataName = dyn_cast<MDString>(ProfileData->getOperand(0));
+ if (!ProfDataName || !ProfDataName->getString().equals("branch_weights"))
+ return false;
+
auto *CITrue = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(1));
auto *CIFalse = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(2));
if (!CITrue || !CIFalse)
return false;
- ProbTrue = CITrue->getValue().getZExtValue();
- ProbFalse = CIFalse->getValue().getZExtValue();
+ TrueVal = CITrue->getValue().getZExtValue();
+ FalseVal = CIFalse->getValue().getZExtValue();
return true;
}
OpenPOWER on IntegriCloud