Go to the documentation of this file.
32 #define DEBUG_TYPE "cross-dso-cfi"
34 STATISTIC(NumTypeIds,
"Number of unique type identifiers");
47 void buildCFICheck(
Module &M);
48 bool runOnModule(
Module &M)
override;
56 char CrossDSOCFI::
ID = 0;
66 auto C = dyn_cast_or_null<ConstantInt>(
TM->getValue());
67 if (!
C)
return nullptr;
69 if (
C->getBitWidth() != 64)
return nullptr;
75 void CrossDSOCFI::buildCFICheck(
Module &M) {
82 GO.getMetadata(LLVMContext::MD_type, Types);
85 TypeIds.
insert(TypeId->getZExtValue());
88 NamedMDNode *CfiFunctionsMD =
M.getNamedMetadata(
"cfi.functions");
90 for (
auto *Func : CfiFunctionsMD->
operands()) {
92 for (
unsigned I = 2;
I <
Func->getNumOperands(); ++
I)
94 extractNumericTypeId(cast<MDNode>(
Func->getOperand(
I).get())))
95 TypeIds.
insert(TypeId->getZExtValue());
107 F->setAlignment(
Align(4096));
110 if (
T.isARM() ||
T.isThumb())
111 F->addFnAttr(
"target-features",
"+thumb-mode");
113 auto args =
F->arg_begin();
115 CallSiteTypeId.
setName(
"CallSiteTypeId");
117 Addr.setName(
"Addr");
119 CFICheckFailData.
setName(
"CFICheckFailData");
130 IRBFail.CreateCall(CFICheckFailFn, {&CFICheckFailData, &
Addr});
131 IRBFail.CreateBr(ExitBB);
134 IRBExit.CreateRetVoid();
147 BranchInst *BI = IRBTest.CreateCondBr(Test, ExitBB, TrapBB);
148 BI->
setMetadata(LLVMContext::MD_prof, VeryLikelyWeights);
150 SI->addCase(CaseTypeId, TestBB);
155 bool CrossDSOCFI::runOnModule(
Module &M) {
158 if (
M.getModuleFlag(
"Cross-DSO CFI") ==
nullptr)
166 bool Changed = Impl.runOnModule(
M);
A set of analyses that are preserved following a run of a transformation pass.
This is an optimization pass for GlobalISel generic memory operations.
ModulePass * createCrossDSOCFIPass()
This pass export CFI checks for use by external modules.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
size_type size() const
Determine the number of elements in the SetVector.
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.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
The instances of the Type class are immutable: once they are created, they are never changed.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
LLVM Basic Block Representation.
This is the shared class of boolean and integer constants.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
(vector float) vec_cmpeq(*A, *B) C
MDNode * createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight)
Return metadata containing two branch weights.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
STATISTIC(NumFunctions, "Total number of functions")
void setName(const Twine &Name)
Change the name of the value.
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
const MDOperand & getOperand(unsigned I) const
This is an important class for using LLVM in a threaded context.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A Module instance is used to store all the information related to an LLVM module.
bool insert(const value_type &X)
Insert a new element into the SetVector.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
void initializeCrossDSOCFIPass(PassRegistry &)
iterator_range< op_iterator > operands()
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=std::nullopt)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
static IntegerType * getInt64Ty(LLVMContext &C)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static Type * getVoidTy(LLVMContext &C)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
A container for analyses that lazily runs them and caches their results.
const char LLVMTargetMachineRef TM
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Conditional or Unconditional Branch instruction.
A vector that has set insertion semantics.
LLVM Value Representation.