35#define DEBUG_TYPE "kcfi"
37STATISTIC(NumKCFIChecks,
"Number of kcfi operands transformed into checks");
44 DiagnosticInfoKCFI(
const Twine &DiagMsg,
53 if (!M.getModuleFlag(
"kcfi"))
59 if (
auto *CI = dyn_cast<CallInst>(&
I))
64 if (KCFICalls.
empty())
71 if (
F.hasFnAttribute(
"patchable-function-prefix"))
73 DiagnosticInfoKCFI(
"-fpatchable-function-entry=N,M, where M>0 is not "
74 "compatible with -fsanitize=kcfi on this target"));
77 MDNode *VeryUnlikelyWeights =
90 Call->copyMetadata(*CI);
91 CI->replaceAllUsesWith(Call);
92 CI->eraseFromParent();
94 if (!Call->isIndirectCall())
100 Int32Ty, Call->getCalledOperand(), -1);
105 Builder.SetInsertPoint(ThenTerm);
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.
print must be executed print the must be executed context for all instructions
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.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static IntegerType * getInt32Ty(LLVMContext &C)
LLVM Value Representation.
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, Instruction *SplitBefore, bool Unreachable, MDNode *BranchWeights, DominatorTree *DT, LoopInfo *LI=nullptr, BasicBlock *ThenBlock=nullptr)
Split the containing block at the specified instruction - everything before SplitBefore stays in the ...