|
LLVM 24.0.0git
|
#include "llvm/Transforms/Scalar/LowerExpectIntrinsic.h"#include "ScalarOptions.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/Constants.h"#include "llvm/IR/Function.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/Intrinsics.h"#include "llvm/IR/LLVMContext.h"#include "llvm/IR/MDBuilder.h"#include "llvm/IR/ProfDataUtils.h"#include "llvm/Transforms/Utils/MisExpect.h"#include <cmath>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "lower-expect-intrinsic" |
Functions | |
| STATISTIC (ExpectIntrinsicsHandled, "Number of 'expect' intrinsic instructions handled") | |
| static std::tuple< uint32_t, uint32_t > | getBranchWeight (const ScalarOptions &Opts, Intrinsic::ID IntrinsicID, CallInst *CI, int BranchCount) |
| static bool | handleSwitchExpect (const ScalarOptions &Opts, SwitchInst &SI) |
| static void | handlePhiDef (const ScalarOptions &Opts, CallInst *Expect) |
| Handler for PHINodes that define the value argument to an @llvm.expect call. | |
| template<class BrSelInst> | |
| static bool | handleBrSelExpect (const ScalarOptions &Opts, BrSelInst &BSI) |
| static bool | lowerExpectIntrinsic (Function &F) |
| #define DEBUG_TYPE "lower-expect-intrinsic" |
Definition at line 31 of file LowerExpectIntrinsic.cpp.
|
static |
Definition at line 44 of file LowerExpectIntrinsic.cpp.
References assert(), llvm::cast(), llvm::CallBase::getArgOperand(), and llvm::User::getNumOperands().
Referenced by handleBrSelExpect(), handlePhiDef(), and handleSwitchExpect().
|
static |
Definition at line 264 of file LowerExpectIntrinsic.cpp.
References llvm::misexpect::checkFrontendInstrumentation(), llvm::MDBuilder::createBranchWeights(), llvm::dyn_cast(), llvm::CallBase::getArgOperand(), llvm::ConstantInt::getBitWidth(), getBranchWeight(), llvm::CallBase::getCalledFunction(), llvm::Value::getContext(), llvm::Function::getIntrinsicID(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::ConstantInt::getZExtValue(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::User::setOperand(), and uint64_t.
Referenced by lowerExpectIntrinsic().
Handler for PHINodes that define the value argument to an @llvm.expect call.
If the operand of the phi has a constant value and it 'contradicts' with the expected value of phi def, then the corresponding incoming edge of the phi is unlikely to be taken. Using that information, the branch probability info for the originating branch can be inferred.
Definition at line 107 of file LowerExpectIntrinsic.cpp.
References llvm::cast(), llvm::MDBuilder::createBranchWeights(), llvm::dyn_cast(), llvm::CallBase::getArgOperand(), getBranchWeight(), llvm::CallBase::getCalledFunction(), llvm::Function::getIntrinsicID(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getSinglePredecessor(), llvm::CondBrInst::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::ConstantInt::getValue(), llvm::isa(), llvm_unreachable, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::reverse(), llvm::Instruction::setMetadata(), and std::swap().
Referenced by lowerExpectIntrinsic().
|
static |
Definition at line 67 of file LowerExpectIntrinsic.cpp.
References llvm::misexpect::checkExpectAnnotations(), llvm::dyn_cast(), llvm::CallBase::getArgOperand(), getBranchWeight(), llvm::CallBase::getCalledFunction(), llvm::SwitchInst::CaseHandleImpl< SwitchInstT, ConstantIntT, BasicBlockT >::getCaseIndex(), llvm::Function::getIntrinsicID(), llvm::setBranchWeights(), and uint64_t.
Referenced by lowerExpectIntrinsic().
Definition at line 345 of file LowerExpectIntrinsic.cpp.
References Changed, llvm::dyn_cast(), llvm::Instruction::eraseFromParent(), F, llvm::CallBase::getArgOperand(), llvm::CallBase::getCalledFunction(), llvm::Function::getIntrinsicID(), handleBrSelExpect(), handlePhiDef(), handleSwitchExpect(), llvm::make_early_inc_range(), llvm::Value::replaceAllUsesWith(), and llvm::reverse().
Referenced by llvm::LowerExpectIntrinsicPass::run().
| STATISTIC | ( | ExpectIntrinsicsHandled | , |
| "Number of 'expect' intrinsic instructions handled" | ) |