LLVM: lib/Transforms/Utils/SanitizerStats.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

20

21using namespace llvm;

22

25 EmptyModuleStatsTy = makeModuleStatsTy();

26

27 ModuleStatsGV = new GlobalVariable(*M, EmptyModuleStatsTy, false,

29}

30

31ArrayType *SanitizerStatReport::makeModuleStatsArrayTy() {

33}

34

35StructType *SanitizerStatReport::makeModuleStatsTy() {

37 {PointerType::getUnqual(M->getContext()),

38 Type::getInt32Ty(M->getContext()),

39 makeModuleStatsArrayTy()});

40}

41

43 Function *F = B.GetInsertBlock()->getParent();

44 Module *M = F->getParent();

46 IntegerType *IntPtrTy = B.getIntPtrTy(M->getDataLayout());

48

50 StatTy,

55 PtrTy)}));

56

59 M->getOrInsertFunction("__sanitizer_stat_report", StatReportTy);

60

62 EmptyModuleStatsTy, ModuleStatsGV,

64 ConstantInt::get(IntPtrTy, 0), ConstantInt::get(B.getInt32Ty(), 2),

65 ConstantInt::get(IntPtrTy, Inits.size() - 1),

66 });

67 B.CreateCall(StatReport, InitAddr);

68}

69

71 if (Inits.empty()) {

72 ModuleStatsGV->eraseFromParent();

73 return;

74 }

75

79

80

81

86 ConstantInt::get(Int32Ty, Inits.size()),

89 ModuleStatsGV->eraseFromParent();

90

91

96

99 M->getOrInsertFunction("__sanitizer_stat_init", StatInitTy);

100

101 B.CreateCall(StatInit, NewModuleStatsGV);

102 B.CreateRetVoid();

103

105}

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

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.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

Class to represent array types.

static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)

This static method is the primary way to construct an ArrayType.

static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)

Creates a new BasicBlock.

static LLVM_ABI Constant * get(ArrayType *T, ArrayRef< Constant * > V)

static LLVM_ABI Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)

static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, GEPNoWrapFlags NW=GEPNoWrapFlags::none(), std::optional< ConstantRange > InRange=std::nullopt, Type *OnlyIfReducedTy=nullptr)

Getelementptr form.

static Constant * getAnon(ArrayRef< Constant * > V, bool Packed=false)

Return an anonymous struct that has the specified elements.

static LLVM_ABI Constant * getNullValue(Type *Ty)

Constructor to create a '0' constant of arbitrary type.

A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...

Class to represent function types.

static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)

This static method is the primary way of constructing a FunctionType.

static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)

@ InternalLinkage

Rename collisions when linking (static functions).

This provides a uniform API for creating instructions and inserting them into a basic block: either a...

Class to represent integer types.

unsigned getBitWidth() const

Get the number of bits in this IntegerType.

A Module instance is used to store all the information related to an LLVM module.

Class to represent pointers.

static PointerType * getUnqual(Type *ElementType)

This constructs a pointer to an object of the specified type in the default address space (address sp...

Class to represent struct types.

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.

The instances of the Type class are immutable: once they are created, they are never changed.

static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)

static LLVM_ABI Type * getVoidTy(LLVMContext &C)

LLVM_ABI void replaceAllUsesWith(Value *V)

Change all uses of this to point to a new Value.

This is an optimization pass for GlobalISel generic memory operations.

FunctionAddr VTableAddr uintptr_t uintptr_t Int32Ty

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.

LLVM_ABI void finish()

Finalize module stats array and add global constructor to register it.

Definition SanitizerStats.cpp:70

LLVM_ABI SanitizerStatReport(Module *M)

Definition SanitizerStats.cpp:23

LLVM_ABI void create(IRBuilder<> &B, SanitizerStatKind SK)

Generates code into B that increments a location-specific counter tagged with the given sanitizer kin...

Definition SanitizerStats.cpp:42