diff options
| author | 2012-05-11 13:17:49 -0700 | |
|---|---|---|
| committer | 2012-05-12 00:57:37 -0700 | |
| commit | ac7b5bb79899865b2375d14bc3af2079ec2eb28d (patch) | |
| tree | a835cbd1158a04bb01ea3505a6a5e561e0f9d527 /src/compiler_llvm/ir_builder.h | |
| parent | 6819a91aa4e9c59a555a8fd14f4be263ae5d8dbb (diff) | |
Add support for llvm static branch prediction.
Change-Id: I8025db404d59a7ef17e4f8b878d0ab5c8cf7dab4
Diffstat (limited to 'src/compiler_llvm/ir_builder.h')
| -rw-r--r-- | src/compiler_llvm/ir_builder.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/compiler_llvm/ir_builder.h b/src/compiler_llvm/ir_builder.h index a700c69a65..aa261c3bb6 100644 --- a/src/compiler_llvm/ir_builder.h +++ b/src/compiler_llvm/ir_builder.h @@ -111,6 +111,24 @@ class IRBuilder : public LLVMIRBuilder { //-------------------------------------------------------------------------- + // Static Branch Prediction + //-------------------------------------------------------------------------- + + // Import the orignal conditional branch + using LLVMIRBuilder::CreateCondBr; + llvm::BranchInst* CreateCondBr(llvm::Value *cond, + llvm::BasicBlock* true_bb, + llvm::BasicBlock* false_bb, + ExpectCond expect) { + DCHECK_NE(expect, MAX_EXPECT) << "MAX_EXPECT is not for branch weight"; + + llvm::BranchInst* branch_inst = LLVMIRBuilder::CreateCondBr(cond, true_bb, false_bb); + branch_inst->setMetadata(llvm::LLVMContext::MD_prof, expect_cond_[expect]); + return branch_inst; + } + + + //-------------------------------------------------------------------------- // Pointer Arithmetic Helper Function //-------------------------------------------------------------------------- @@ -384,6 +402,7 @@ class IRBuilder : public LLVMIRBuilder { RuntimeSupportBuilder* runtime_support_; + llvm::MDNode* expect_cond_[MAX_EXPECT]; }; |