31#define DEBUG_TYPE "kcfi"
33STATISTIC(NumKCFIChecks,
"Number of kcfi operands transformed into checks");
43 void print(DiagnosticPrinter &DP)
const override { DP << Msg; }
48 MDNode *VeryUnlikelyWeights) {
58 Call->copyMetadata(*CI);
62 if (!
Call->isIndirectCall())
67 Builder.disableGEPCanonicalization();
68 Value *FuncPtr =
Call->getCalledOperand();
73 if (
T.isARM() ||
T.isThumb()) {
74 FuncPtr = Builder.CreateIntToPtr(
75 Builder.CreateAnd(Builder.CreatePtrToInt(FuncPtr, Int32Ty),
79 Value *HashPtr = Builder.CreateConstInBoundsGEP1_32(Int32Ty, FuncPtr, -1);
80 Value *
Test = Builder.CreateICmpNE(Builder.CreateLoad(Int32Ty, HashPtr),
81 ConstantInt::get(Int32Ty, ExpectedHash));
84 Builder.SetInsertPoint(ThenTerm);
85 Builder.CreateIntrinsic(Intrinsic::debugtrap, {});
98 if (TrapCalls.
empty())
106 if (
F.hasFnAttribute(
"patchable-function-prefix"))
108 DiagnosticInfoKCFI(
"-fpatchable-function-entry=N,M, where M>0 is not "
109 "compatible with -fsanitize=kcfi on this target"));
121 if (!
F.getParent()->getModuleFlag(
"kcfi"))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Expand Atomic instructions
#define LLVM_LIFETIME_BOUND
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Module.h This file contains the declarations for the Module class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
std::optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Return an operand bundle by name, if present.
static LLVM_ABI CallBase * removeOperandBundle(CallBase *CB, uint32_t ID, InsertPosition InsertPt=nullptr)
Create a clone of CB with operand bundle ID removed.
This class represents a function call, abstracting a target machine's calling convention.
static ConstantInt * getSigned(IntegerType *Ty, int64_t V, bool ImplicitTrunc=false)
Return a ConstantInt with the specified value for the specified type.
This is the base abstract class for diagnostic reporting in the backend.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
Class to represent integer types.
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
This is an important class for using LLVM in a threaded context.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
LLVM_ABI MDNode * createUnlikelyBranchWeights()
Return metadata containing two branch weights, with significant bias towards false destination.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
self_iterator getIterator()
This is an optimization pass for GlobalISel generic memory operations.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI Instruction * SplitBlockAndInsertIfThen(Value *Cond, BasicBlock::iterator SplitBefore, bool Unreachable, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, BasicBlock *ThenBlock=nullptr)
Split the containing block at the specified instruction - everything before SplitBefore stays in the ...
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.