summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2015-01-24 10:30:14 +0000
committerChandler Carruth <chandlerc@gmail.com>2015-01-24 10:30:14 +0000
commit0ea746bf9f102c313f5f4251b7b7bdceec0cec13 (patch)
treed4a931daca3073e0113f377583cabf4f33b76d19 /llvm/lib/Transforms
parent72793727cc7aa192e8e2b5b18776144543118af8 (diff)
downloadbcm5719-llvm-0ea746bf9f102c313f5f4251b7b7bdceec0cec13.tar.gz
bcm5719-llvm-0ea746bf9f102c313f5f4251b7b7bdceec0cec13.zip
[PM] Clean up the formatting of the LowerExpectIntrinsic pass prior to
refactoring its code. llvm-svn: 226992
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp40
1 files changed, 17 insertions, 23 deletions
diff --git a/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp b/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
index ff89e747440..3a0474279a6 100644
--- a/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
@@ -40,24 +40,22 @@ UnlikelyBranchWeight("unlikely-branch-weight", cl::Hidden, cl::init(4),
cl::desc("Weight of the branch unlikely to be taken (default = 4)"));
namespace {
+class LowerExpectIntrinsic : public FunctionPass {
- class LowerExpectIntrinsic : public FunctionPass {
+ bool HandleSwitchExpect(SwitchInst *SI);
- bool HandleSwitchExpect(SwitchInst *SI);
+ bool HandleIfExpect(BranchInst *BI);
- bool HandleIfExpect(BranchInst *BI);
-
- public:
- static char ID;
- LowerExpectIntrinsic() : FunctionPass(ID) {
- initializeLowerExpectIntrinsicPass(*PassRegistry::getPassRegistry());
- }
+public:
+ static char ID;
+ LowerExpectIntrinsic() : FunctionPass(ID) {
+ initializeLowerExpectIntrinsicPass(*PassRegistry::getPassRegistry());
+ }
- bool runOnFunction(Function &F) override;
- };
+ bool runOnFunction(Function &F) override;
+};
}
-
bool LowerExpectIntrinsic::HandleSwitchExpect(SwitchInst *SI) {
CallInst *CI = dyn_cast<CallInst>(SI->getCondition());
if (!CI)
@@ -76,11 +74,11 @@ bool LowerExpectIntrinsic::HandleSwitchExpect(SwitchInst *SI) {
unsigned n = SI->getNumCases(); // +1 for default case.
std::vector<uint32_t> Weights(n + 1);
- Weights[0] = Case == SI->case_default() ? LikelyBranchWeight
- : UnlikelyBranchWeight;
+ Weights[0] =
+ Case == SI->case_default() ? LikelyBranchWeight : UnlikelyBranchWeight;
for (unsigned i = 0; i != n; ++i)
- Weights[i + 1] = i == Case.getCaseIndex() ? LikelyBranchWeight
- : UnlikelyBranchWeight;
+ Weights[i + 1] =
+ i == Case.getCaseIndex() ? LikelyBranchWeight : UnlikelyBranchWeight;
SI->setMetadata(LLVMContext::MD_prof,
MDBuilder(CI->getContext()).createBranchWeights(Weights));
@@ -89,7 +87,6 @@ bool LowerExpectIntrinsic::HandleSwitchExpect(SwitchInst *SI) {
return true;
}
-
bool LowerExpectIntrinsic::HandleIfExpect(BranchInst *BI) {
if (BI->isUnconditional())
return false;
@@ -145,7 +142,6 @@ bool LowerExpectIntrinsic::HandleIfExpect(BranchInst *BI) {
return true;
}
-
bool LowerExpectIntrinsic::runOnFunction(Function &F) {
for (Function::iterator I = F.begin(), E = F.end(); I != E;) {
BasicBlock *BB = I++;
@@ -160,8 +156,7 @@ bool LowerExpectIntrinsic::runOnFunction(Function &F) {
}
// remove llvm.expect intrinsics.
- for (BasicBlock::iterator BI = BB->begin(), BE = BB->end();
- BI != BE; ) {
+ for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE;) {
CallInst *CI = dyn_cast<CallInst>(BI++);
if (!CI)
continue;
@@ -178,10 +173,9 @@ bool LowerExpectIntrinsic::runOnFunction(Function &F) {
return false;
}
-
char LowerExpectIntrinsic::ID = 0;
-INITIALIZE_PASS(LowerExpectIntrinsic, "lower-expect", "Lower 'expect' "
- "Intrinsics", false, false)
+INITIALIZE_PASS(LowerExpectIntrinsic, "lower-expect",
+ "Lower 'expect' Intrinsics", false, false)
FunctionPass *llvm::createLowerExpectIntrinsicPass() {
return new LowerExpectIntrinsic();
OpenPOWER on IntegriCloud