LLVM: lib/Transforms/Instrumentation/BoundsChecking.cpp File Reference (original) (raw)

Go to the source code of this file.

Macros
#define DEBUG_TYPE "bounds-checking"
Functions
STATISTIC (ChecksAdded, "Bounds checks added")
STATISTIC (ChecksSkipped, "Bounds checks skipped")
STATISTIC (ChecksUnable, "Bounds checks unable to add")
static Value * getBoundsCheckCond (Value *Ptr, Value *InstVal, const DataLayout &DL, TargetLibraryInfo &TLI, ObjectSizeOffsetEvaluator &ObjSizeEval, BuilderTy &IRB, ScalarEvolution &SE)
Gets the conditions under which memory accessing instructions will overflow.
static CallInst * InsertTrap (BuilderTy &IRB, bool DebugTrapBB, std::optional< int8_t > GuardKind)
static CallInst * InsertCall (BuilderTy &IRB, bool MayReturn, StringRef Name)
template
static void insertBoundsCheck (Value *Or, BuilderTy &IRB, GetTrapBBT GetTrapBB)
Adds run-time bounds checks to memory accessing instructions.
static std::string getRuntimeCallName (const BoundsCheckingPass::Options::Runtime &Opts)
static bool addBoundsChecking (Function &F, TargetLibraryInfo &TLI, ScalarEvolution &SE, const BoundsCheckingPass::Options &Opts)

DEBUG_TYPE

#define DEBUG_TYPE "bounds-checking"

addBoundsChecking()

Definition at line 186 of file BoundsChecking.cpp.

References llvm::CallBase::addFnAttr(), llvm::BasicBlock::Create(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateIntrinsic(), DL, llvm::dyn_cast(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::ObjectSizeOpts::EvalMode, llvm::ObjectSizeOpts::ExactUnderlyingSizeAndOffset, F, getBoundsCheckCond(), llvm::Function::getContext(), llvm::IRBuilderBase::getInt1Ty(), llvm::GlobalValue::getParent(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), getRuntimeCallName(), llvm::BoundsCheckingPass::Options::GuardKind, I, insertBoundsCheck(), InsertCall(), InsertTrap(), instructions, llvm::BoundsCheckingPass::Options::Merge, llvm::CallingConv::PreserveAll, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::ObjectSizeOpts::RoundToAlign, llvm::BoundsCheckingPass::Options::Rt, llvm::CallBase::setCallingConv(), llvm::Instruction::setDebugLoc(), llvm::CallBase::setDoesNotReturn(), llvm::CallBase::setDoesNotThrow(), and SingleTrapBB.

Referenced by llvm::BoundsCheckingPass::run().

getBoundsCheckCond()

Gets the conditions under which memory accessing instructions will overflow.

Ptr is the pointer that will be read/written, and InstVal is either the result from the load or the value being stored. It is used to determine the size of memory block that is touched.

Returns the condition under which the access will overflow.

Definition at line 59 of file BoundsChecking.cpp.

References llvm::SizeOffsetType< T, C >::bothKnown(), llvm::ObjectSizeOffsetEvaluator::compute(), llvm::IRBuilderBase::CreateICmpSLT(), llvm::IRBuilderBase::CreateICmpULT(), llvm::IRBuilderBase::CreateOr(), llvm::IRBuilderBase::CreateSub(), llvm::IRBuilderBase::CreateTypeSize(), llvm::dbgs(), DL, llvm::dyn_cast(), llvm::Value::getContext(), llvm::ConstantInt::getFalse(), llvm::ScalarEvolution::getSCEV(), llvm::Value::getType(), llvm::ScalarEvolution::getUnsignedRange(), llvm::ConstantInt::getValue(), LLVM_DEBUG, llvm::Offset, llvm::SizeOffsetType< T, C >::Offset, Size, llvm::SizeOffsetType< T, C >::Size, and llvm::APInt::slt().

Referenced by addBoundsChecking().

getRuntimeCallName()

insertBoundsCheck()

template

void insertBoundsCheck ( Value * Or, BuilderTy & IRB, GetTrapBBT GetTrapBB ) static

InsertCall()

InsertTrap()

STATISTIC() [1/3]

STATISTIC ( ChecksAdded ,
"Bounds checks added" )

STATISTIC() [2/3]

STATISTIC ( ChecksSkipped ,
"Bounds checks skipped" )

STATISTIC() [3/3]

STATISTIC ( ChecksUnable ,
"Bounds checks unable to add" )

SingleTrapBB