diff options
| author | Rong Xu <xur@google.com> | 2017-08-23 21:36:02 +0000 |
|---|---|---|
| committer | Rong Xu <xur@google.com> | 2017-08-23 21:36:02 +0000 |
| commit | 15848e597710e1d62ee4165495871861ac923aef (patch) | |
| tree | 2b6736345e442675bbd9620b90495826a6970c18 /llvm/lib | |
| parent | 8040a215c901f28cd29ed516254607532a61b06b (diff) | |
| download | bcm5719-llvm-15848e597710e1d62ee4165495871861ac923aef.tar.gz bcm5719-llvm-15848e597710e1d62ee4165495871861ac923aef.zip | |
[PGO] Set edge weights for indirectbr instruction with profile counts
Current PGO only annotates the edge weight for branch and switch instructions
with profile counts. We should also annotate the indirectbr instruction as
all the information is there. This patch enables the annotating for indirectbr
instructions. Also uses this annotation in branch probability analysis.
Differential Revision: https://reviews.llvm.org/D37074
llvm-svn: 311604
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/BranchProbabilityInfo.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp index 6008c353a08..11f2bcc4703 100644 --- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp +++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp @@ -237,7 +237,7 @@ bool BranchProbabilityInfo::calcUnreachableHeuristics(const BasicBlock *BB) { bool BranchProbabilityInfo::calcMetadataWeights(const BasicBlock *BB) { const TerminatorInst *TI = BB->getTerminator(); assert(TI->getNumSuccessors() > 1 && "expected more than one successor!"); - if (!isa<BranchInst>(TI) && !isa<SwitchInst>(TI)) + if (!(isa<BranchInst>(TI) || isa<SwitchInst>(TI) || isa<IndirectBrInst>(TI))) return false; MDNode *WeightsNode = TI->getMetadata(LLVMContext::MD_prof); diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index ef955f17bfa..7b8e05b2ed2 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -1094,7 +1094,8 @@ void PGOUseFunc::setBranchWeights() { TerminatorInst *TI = BB.getTerminator(); if (TI->getNumSuccessors() < 2) continue; - if (!isa<BranchInst>(TI) && !isa<SwitchInst>(TI)) + if (!(isa<BranchInst>(TI) || isa<SwitchInst>(TI) || + isa<IndirectBrInst>(TI))) continue; if (getBBInfo(&BB).CountValue == 0) continue; |

