45#define DEBUG_TYPE "tysan"
53 "__tysan_shadow_memory_address";
56STATISTIC(NumInstrumentedAccesses,
"Number of instrumented accesses");
63 TypeSanitizer(
const InstrumentationOptions &Opts,
Module &M);
65 void instrumentGlobals(
Module &M);
67 const InstrumentationOptions &Opts;
68 bool OutlineInstrumentation;
75 void initializeCallbacks(
Module &M);
82 bool IsWrite,
Value *ShadowBase,
83 Value *AppMemMask,
bool ForceSetType,
84 bool SanitizeFunction,
85 TypeDescriptorsMapTy &TypeDescriptors,
93 std::string getAnonymousStructIdentifier(
const MDNode *MD,
94 TypeNameMapTy &TypeNames);
95 bool generateTypeDescriptor(
const MDNode *MD,
96 TypeDescriptorsMapTy &TypeDescriptors,
97 TypeNameMapTy &TypeNames,
Module &M);
98 bool generateBaseTypeDescriptor(
const MDNode *MD,
99 TypeDescriptorsMapTy &TypeDescriptors,
100 TypeNameMapTy &TypeNames,
Module &M);
102 const Triple TargetTriple;
117 Function *TysanGlobalsSetTypeFunction;
121TypeSanitizer::TypeSanitizer(
const InstrumentationOptions &Opts,
Module &M)
122 : Opts(Opts), OutlineInstrumentation(Opts.tysan_outline_instrumentation),
123 TargetTriple(M.getTargetTriple()),
124 AnonNameRegex(
"^_ZTS.*N[1-9][0-9]*_GLOBAL__N") {
126 IntptrTy =
DL.getIntPtrType(M.getContext());
127 PtrShift =
countr_zero(IntptrTy->getPrimitiveSizeInBits() / 8);
129 TysanGlobalsSetTypeFunction = M.getFunction(
"__tysan_set_globals_types");
130 initializeCallbacks(M);
133void TypeSanitizer::initializeCallbacks(
Module &M) {
134 LLVMContext &
C =
M.getContext();
141 Attr = Attr.addFnAttribute(
C, Attribute::NoUnwind);
142 Attribute::AttrKind SExtAttr =
143 TargetLibraryInfo::getExtAttrForI32Param(TargetTriple,
true);
144 Attribute::AttrKind BoolExtAttr =
150 Attr.maybeAddParamAttribute(
C, 1, SExtAttr)
151 .maybeAddParamAttribute(
C, 3, SExtAttr),
162 TysanIntrumentMemInst =
M.getOrInsertFunction(
163 "__tysan_instrument_mem_inst",
164 Attr.maybeAddParamAttribute(
C, 3, BoolExtAttr), IRB.getVoidTy(),
171 TysanInstrumentWithShadowUpdate =
172 M.getOrInsertFunction(
"__tysan_instrument_with_shadow_update",
173 Attr.maybeAddParamAttribute(
C, 2, BoolExtAttr)
174 .maybeAddParamAttribute(
C, 4, SExtAttr),
183 TysanSetShadowType =
M.getOrInsertFunction(
184 "__tysan_set_shadow_type", Attr, IRB.getVoidTy(),
191void TypeSanitizer::instrumentGlobals(
Module &M) {
192 TysanGlobalsSetTypeFunction =
nullptr;
194 NamedMDNode *Globals =
M.getNamedMetadata(
"llvm.tysan.globals");
199 FunctionType::get(Type::getVoidTy(
M.getContext()),
false),
205 const DataLayout &
DL =
M.getDataLayout();
206 Value *ShadowBase = getShadowBase(*TysanGlobalsSetTypeFunction);
207 Value *AppMemMask = getAppMemMask(*TysanGlobalsSetTypeFunction);
208 TypeDescriptorsMapTy TypeDescriptors;
209 TypeNameMapTy TypeNames;
211 for (
const auto &GMD : Globals->
operands()) {
215 const MDNode *TBAAMD =
cast<MDNode>(GMD->getOperand(1));
216 if (!generateBaseTypeDescriptor(TBAAMD, TypeDescriptors, TypeNames, M))
221 Type *AccessTy = GV->getValueType();
223 uint64_t AccessSize =
DL.getTypeStoreSize(AccessTy);
224 instrumentWithShadowUpdate(IRB, TBAAMD, GV, AccessSize,
false,
false,
225 ShadowBase, AppMemMask,
true,
false,
226 TypeDescriptors,
DL);
229 if (TysanGlobalsSetTypeFunction) {
233 IRB.CreateCall(TysanGlobalsSetTypeFunction, {});
237static const char LUT[] =
"0123456789abcdef";
240 size_t Length = Name.size();
242 Output.reserve(Output.size() + 3 *
Length);
243 for (
size_t i = 0; i <
Length; ++i) {
244 const unsigned char c = Name[i];
255 Output.push_back(
'_');
256 Output.push_back(
LUT[c >> 4]);
257 Output.push_back(
LUT[c & 15]);
264TypeSanitizer::getAnonymousStructIdentifier(
const MDNode *MD,
265 TypeNameMapTy &TypeNames) {
273 auto TNI = TypeNames.find(MemberNode);
274 std::string MemberName;
275 if (TNI != TypeNames.end()) {
276 MemberName = TNI->second;
284 if (MemberName.empty())
285 MemberName = getAnonymousStructIdentifier(MemberNode, TypeNames);
286 if (MemberName.empty())
288 TypeNames[MemberNode] = MemberName;
300 MD5::MD5Result HashResult;
301 Hash.
final(HashResult);
302 return "__anonymous_" + std::string(HashResult.
digest().
str());
305bool TypeSanitizer::generateBaseTypeDescriptor(
306 const MDNode *MD, TypeDescriptorsMapTy &TypeDescriptors,
307 TypeNameMapTy &TypeNames,
Module &M) {
317 Name = getAnonymousStructIdentifier(MD, TypeNames);
320 TypeNames[MD] =
Name;
326 TypeDescriptors[MD] = GV;
337 auto TDI = TypeDescriptors.find(MemberNode);
338 if (TDI != TypeDescriptors.end()) {
341 if (!generateBaseTypeDescriptor(MemberNode, TypeDescriptors, TypeNames,
345 Member = TypeDescriptors[MemberNode];
375 PushTDSub(ConstantInt::get(IntptrTy, 2));
376 PushTDSub(ConstantInt::get(IntptrTy, Members.
size()));
384 bool ShouldBeComdat = !AnonNameRegex.
match(NameNode->
getString());
385 for (
auto &Member : Members) {
387 PushTDSub(ConstantInt::get(IntptrTy,
Member.second));
395 GlobalVariable *TDGV =
396 new GlobalVariable(TDTy,
true,
400 M.insertGlobalVariable(TDGV);
402 if (ShouldBeComdat) {
404 Comdat *TDComdat =
M.getOrInsertComdat(EncodedName);
410 TypeDescriptors[MD] = TDGV;
414bool TypeSanitizer::generateTypeDescriptor(
415 const MDNode *MD, TypeDescriptorsMapTy &TypeDescriptors,
416 TypeNameMapTy &TypeNames,
Module &M) {
435 auto TDI = TypeDescriptors.find(BaseNode);
436 if (TDI != TypeDescriptors.end()) {
439 if (!generateBaseTypeDescriptor(BaseNode, TypeDescriptors, TypeNames, M))
442 Base = TypeDescriptors[BaseNode];
446 TDI = TypeDescriptors.find(AccessNode);
447 if (TDI != TypeDescriptors.end()) {
450 if (!generateBaseTypeDescriptor(AccessNode, TypeDescriptors, TypeNames, M))
453 Access = TypeDescriptors[AccessNode];
458 std::string EncodedName =
464 TypeDescriptors[MD] = GV;
475 ConstantInt::get(IntptrTy,
Offset));
480 GlobalVariable *TDGV =
481 new GlobalVariable(TDTy,
true,
485 M.insertGlobalVariable(TDGV);
487 if (ShouldBeComdat) {
489 Comdat *TDComdat =
M.getOrInsertComdat(EncodedName);
495 TypeDescriptors[MD] = TDGV;
503 return IRB.CreateLoad(IntptrTy, GlobalShadowAddress,
"shadow.base");
508 Value *GlobalAppMemMask =
510 return IRB.CreateLoad(IntptrTy, GlobalAppMemMask,
"app.mem.mask");
517 SmallVectorImpl<std::pair<Instruction *, MemoryLocation>> &MemoryAccesses,
523 if (Inst.getMetadata(LLVMContext::MD_nosanitize))
541 MemoryAccesses.push_back(std::make_pair(&Inst, MLoc));
554bool TypeSanitizer::sanitizeFunction(
Function &
F,
555 const TargetLibraryInfo &TLI) {
556 if (
F.isDeclaration())
558 if (
F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
562 if (&
F == TysanCtorFunction.
getCallee() || &
F == TysanGlobalsSetTypeFunction)
564 initializeCallbacks(*
F.getParent());
569 SmallSetVector<const MDNode *, 8> TBAAMetadata;
575 for (
auto &
A :
F.args())
576 if (
A.hasByValAttr())
580 TypeDescriptorsMapTy TypeDescriptors;
581 TypeNameMapTy TypeNames;
583 for (
const MDNode *MD : TBAAMetadata) {
584 if (TypeDescriptors.count(MD))
587 if (!generateTypeDescriptor(MD, TypeDescriptors, TypeNames, M))
593 const DataLayout &
DL =
F.getDataLayout();
594 bool SanitizeFunction =
F.hasFnAttribute(Attribute::SanitizeType);
595 bool NeedsInstrumentation =
596 MemTypeResetInsts.
empty() && MemoryAccesses.
empty();
597 Instruction *ShadowBase = NeedsInstrumentation ? nullptr : getShadowBase(
F);
598 Instruction *AppMemMask = NeedsInstrumentation ? nullptr : getAppMemMask(
F);
599 for (
const auto &[
I, MLoc] : MemoryAccesses) {
601 assert(MLoc.Size.isPrecise());
602 if (instrumentWithShadowUpdate(
603 IRB, MLoc.AATags.TBAA,
const_cast<Value *
>(MLoc.Ptr),
604 MLoc.Size.getValue(),
I->mayReadFromMemory(),
I->mayWriteToMemory(),
605 ShadowBase, AppMemMask,
false, SanitizeFunction, TypeDescriptors,
607 ++NumInstrumentedAccesses;
612 for (
auto Inst : MemTypeResetInsts)
613 Res |= instrumentMemInst(Inst, ShadowBase, AppMemMask,
DL);
624 AppMemMask,
"app.ptr.masked"),
625 PtrShift,
"app.ptr.shifted"),
626 ShadowBase,
"shadow.ptr.int");
629bool TypeSanitizer::instrumentWithShadowUpdate(
631 bool IsRead,
bool IsWrite,
Value *ShadowBase,
Value *AppMemMask,
632 bool ForceSetType,
bool SanitizeFunction,
633 TypeDescriptorsMapTy &TypeDescriptors,
const DataLayout &
DL) {
636 TDGV = TypeDescriptors[TBAAMD];
642 if (OutlineInstrumentation) {
643 if (!ForceSetType && (!Opts.tysan_writes_always_set_type || IsRead)) {
650 ConstantInt::get(OrdTy, (
int)IsRead | (((
int)IsWrite) << 1));
652 IRB.
CreateCall(TysanInstrumentWithShadowUpdate,
656 }
else if (ForceSetType || IsWrite) {
666 ShadowBase, AppMemMask);
671 auto SetType = [&]() {
676 for (
uint64_t i = 1; i < AccessSize; ++i) {
679 ConstantInt::get(IntptrTy, i << PtrShift),
680 "shadow.byte." + Twine(i) +
".offset"),
681 Int8PtrPtrTy,
"shadow.byte." + Twine(i) +
".ptr");
687 IRB.
getPtrTy(),
"bad.descriptor" + Twine(i));
692 if (ForceSetType || (Opts.tysan_writes_always_set_type && IsWrite)) {
699 assert((!Opts.tysan_writes_always_set_type || IsRead) &&
700 "should have handled case above");
702 MDNode *UnlikelyBW = MDBuilder(
C).createBranchWeights(1, 100000);
704 if (!SanitizeFunction) {
712 NullTDTerm->
getParent()->setName(
"set.type");
771 Constant *
Flags = ConstantInt::get(OrdTy,
int(IsRead) | (
int(IsWrite) << 1));
777 &GoodTDTerm, UnlikelyBW);
792 Value *
Size = ConstantInt::get(OrdTy, AccessSize);
794 for (
uint64_t i = 1; i < AccessSize; ++i) {
796 IRB.
CreateAdd(ShadowDataInt, ConstantInt::get(IntptrTy, i << PtrShift)),
821 for (
uint64_t i = 1; i < AccessSize; ++i) {
823 IRB.
CreateAdd(ShadowDataInt, ConstantInt::get(IntptrTy, i << PtrShift)),
828 NotAllBadTD, IRB.
CreateICmpSGE(ILdTD, ConstantInt::get(IntptrTy, 0)));
839bool TypeSanitizer::instrumentMemInst(
Value *V, Instruction *ShadowBase,
840 Instruction *AppMemMask,
841 const DataLayout &
DL) {
853 BB = &
F->getEntryBlock();
857 if (IP->comesBefore(ShadowBase))
859 if (IP->comesBefore(AppMemMask))
864 bool NeedsMemMove =
false;
868 assert(
A->hasByValAttr() &&
"Type reset for non-byval argument?");
872 ConstantInt::get(IntptrTy,
DL.getTypeAllocSize(
A->getParamByValType()));
876 if (
MI->getDestAddressSpace() != 0)
879 Dest =
MI->getDest();
883 if (MTI->getSourceAddressSpace() == 0) {
884 Src = MTI->getSource();
894 Dest =
II->getArgOperand(0);
909 if (OutlineInstrumentation) {
917 TysanIntrumentMemInst,
922 ShadowBase = getShadowBase(*
F);
924 AppMemMask = getAppMemMask(*
F);
964 std::tie(TysanCtorFunction, std::ignore) =
969 const InstrumentationOptions &Opts =
970 M.getContext().getLibraryOptions().get<InstrumentationOptions>();
971 TypeSanitizer TySan(Opts, M);
972 TySan.instrumentGlobals(M);
978 TySan.sanitizeFunction(
F, TLI);
979 if (Opts.tysan_verify_outlined_instrumentation &&
980 Opts.tysan_outline_instrumentation) {
986 TySan.OutlineInstrumentation =
false;
987 TySan.sanitizeFunction(
F, TLI);
988 TySan.OutlineInstrumentation =
true;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Expand Atomic instructions
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Module.h This file contains the declarations for the Module class.
Machine Check Debug Module
This file provides utility analysis objects describing memory locations.
uint64_t IntrinsicInst * II
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
static const char *const kTysanInitName
static Value * convertToShadowDataInt(IRBuilder<> &IRB, Value *Ptr, Type *IntptrTy, uint64_t PtrShift, Value *ShadowBase, Value *AppMemMask)
static const char *const kTysanShadowMemoryAddress
static const char *const kTysanGVNamePrefix
static const char *const kTysanModuleCtorName
static const char *const kTysanAppMemMask
void collectMemAccessInfo(Function &F, const TargetLibraryInfo &TLI, SmallVectorImpl< std::pair< Instruction *, MemoryLocation > > &MemoryAccesses, SmallSetVector< const MDNode *, 8 > &TBAAMetadata, SmallVectorImpl< Value * > &MemTypeResetInsts)
Collect all loads and stores, and for what TBAA nodes we need to generate type descriptors.
static const char *const kTysanCheckName
static std::string encodeName(StringRef Name)
LLVM_ABI const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
const Function * getParent() const
Return the enclosing method, or null if none.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
InstListType::iterator iterator
Instruction iterators...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
This class represents a function call, abstracting a target machine's calling convention.
static LLVM_ABI Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true, bool ByteString=false)
This method constructs a CDS and initializes it with a text string.
static ConstantInt * getSigned(IntegerType *Ty, int64_t V, bool ImplicitTrunc=false)
Return a ConstantInt with the specified value for the specified type.
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
static LLVM_ABI Constant * get(StructType *T, ArrayRef< Constant * > V)
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
A parsed version of the target data layout string in and methods for querying it.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
const BasicBlock & getEntryBlock() const
LLVM_ABI void setComdat(Comdat *C)
@ InternalLinkage
Rename collisions when linking (static functions).
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
LLVM_ABI Value * CreateAllocationSize(Type *DestTy, AllocaInst *AI)
Get allocation size of an alloca as a runtime Value* (handles both static and dynamic allocas and vsc...
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy.
CallInst * CreateMemCpy(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, uint64_t Size, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
Create and insert a memcpy between the specified pointers.
ConstantInt * getTrue()
Get the constant value for i1 true.
Value * CreateICmpSGE(Value *LHS, Value *RHS, const Twine &Name="")
BasicBlock::iterator GetInsertPoint() const
Value * CreateIntToPtr(Value *V, Type *DestTy, const Twine &Name="")
ConstantInt * getInt8(uint8_t C)
Get a constant 8-bit value.
Value * CreateICmpNE(Value *LHS, Value *RHS, const Twine &Name="")
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
CallInst * CreateMemMove(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, uint64_t Size, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, MaybeAlign Align, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
Create and insert a memset to the specified pointer and the specified value.
LLVMContext & getContext() const
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreatePtrToInt(Value *V, Type *DestTy, const Twine &Name="")
ConstantInt * getFalse()
Get the constant value for i1 false.
Value * CreateIsNotNull(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg != 0.
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
PointerType * getPtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer.
Value * CreateIsNull(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg == 0.
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
LLVM_ABI void SetInstDebugLocation(Instruction *I) const
If this builder has a current debug location, set it on the specified instruction.
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="", bool IsDisjoint=false)
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Class to represent integer types.
LLVM_ABI void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
LLVM_ABI void final(MD5Result &Result)
Finishes off the hash and puts the result in result.
const MDOperand & getOperand(unsigned I) const
unsigned getNumOperands() const
Return number of MDNode operands.
LLVMContext & getContext() const
LLVM_ABI StringRef getString() const
Representation for a specific memory location.
static LLVM_ABI MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
AAMDNodes AATags
The metadata nodes which describes the aliasing of the location (each member is null if that kind of ...
const Value * Ptr
The address of the start of the location.
A Module instance is used to store all the information related to an LLVM module.
iterator_range< op_iterator > operands()
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.
LLVM_ABI bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr, std::string *Error=nullptr) const
matches - Match the regex against a given String.
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, InsertPosition InsertBefore=nullptr)
bool insert(const value_type &X)
Insert a new element into the SetVector.
A SetVector that performs no allocations if smaller than a certain size.
StringRef str() const
Explicit conversion to StringRef.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
Represent a constant reference to a string, i.e.
std::string str() const
Get the contents as an std::string.
static LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Analysis pass providing the TargetLibraryInfo.
Provides information about what library functions are available for the current target.
static Attribute::AttrKind getExtAttrForBoolParam(const Triple &T)
Triple - Helper class for working with autoconf configuration names.
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
bool isSized() const
Return true if it makes sense to take the size of this type.
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI bool isSwiftError() const
Return true if this value is a swifterror value.
const ParentTy * getParent() const
self_iterator getIterator()
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
@ BasicBlock
Various leaf nodes.
@ Size64
A 64-bit size relocation.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract_or_null(Y &&MD)
Extract a Value from Metadata, if any, allowing null.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
std::string utostr(uint64_t X, bool isNeg=false)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
auto dyn_cast_or_null(const Y &Val)
LLVM_ABI std::pair< Function *, FunctionCallee > createSanitizerCtorAndInitFunctions(Module &M, StringRef CtorName, StringRef InitName, ArrayRef< Type * > InitArgTypes, ArrayRef< Value * > InitArgs, StringRef VersionCheckName=StringRef(), bool Weak=false)
Creates sanitizer constructor function, and calls sanitizer's init function from it.
LLVM_ABI void SplitBlockAndInsertIfThenElse(Value *Cond, BasicBlock::iterator SplitBefore, Instruction **ThenTerm, Instruction **ElseTerm, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr)
SplitBlockAndInsertIfThenElse is similar to SplitBlockAndInsertIfThen, but also creates the ElseBlock...
IRBuilder(LLVMContext &, FolderTy, InserterTy) -> IRBuilder< FolderTy, InserterTy >
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI void appendToGlobalCtors(Module &M, Function *F, int Priority, Constant *Data=nullptr)
Append F to the list of global ctors of module M with the given Priority.
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 ...
LLVM_ABI void maybeMarkSanitizerLibraryCallNoBuiltin(CallInst *CI, const TargetLibraryInfo *TLI)
Given a CallInst, check if it calls a string function known to CodeGen, and mark it with NoBuiltin if...
LLVM_ABI void appendToUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.used list.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
MDNode * TBAA
The tag for type-based alias analysis.
static constexpr Align fromLog2(unsigned Log2Value)
Returns an alignment of 1 << Log2Value bytes.
LLVM_ABI SmallString< 32 > digest() const
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)