32#define DEBUG_TYPE "kcfi"
34STATISTIC(NumKCFIChecks,
"Number of kcfi operands transformed into checks");
41 DiagnosticInfoKCFI(
const Twine &DiagMsg,
50 if (!M.getModuleFlag(
"kcfi"))
56 if (
auto *CI = dyn_cast<CallInst>(&
I))
61 if (KCFICalls.
empty())
68 if (
F.hasFnAttribute(
"patchable-function-prefix"))
70 DiagnosticInfoKCFI(
"-fpatchable-function-entry=N,M, where M>0 is not "
71 "compatible with -fsanitize=kcfi on this target"));
74 MDNode *VeryUnlikelyWeights =
88 Call->copyMetadata(*CI);
89 CI->replaceAllUsesWith(Call);
90 CI->eraseFromParent();
92 if (!Call->isIndirectCall())
97 Value *FuncPtr = Call->getCalledOperand();
102 if (
T.isARM() ||
T.isThumb()) {
103 FuncPtr =
Builder.CreateIntToPtr(
113 Builder.SetInsertPoint(ThenTerm);
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Select target instructions out of generic instructions
Module.h This file contains the declarations for the Module class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
A container for analyses that lazily runs them and caches their results.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
static CallBase * removeOperandBundle(CallBase *CB, uint32_t ID, Instruction *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 Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
This is the base abstract class for diagnostic reporting in the backend.
virtual void print(DiagnosticPrinter &DP) const =0
Print using the given DP a user-friendly message.
Interface for custom diagnostic printing.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Class to represent integer types.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
This is an important class for using LLVM in a threaded context.
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
MDNode * createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight)
Return metadata containing two branch weights.
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 IntegerType * getInt32Ty(LLVMContext &C)
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
const CustomOperand< const MCSubtargetInfo & > Msg[]
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=std::nullopt)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
This is an optimization pass for GlobalISel generic memory operations.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
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 ...