26 #define AVR_INSTRUMENT_FUNCTIONS_NAME "AVR function instrumentation pass"
33 #define SYMBOL_PREFIX "avr_instrumentation"
75 static std::string GetTypeName(
Type &Ty) {
76 if (
auto *IntTy = dyn_cast<IntegerType>(&Ty)) {
106 return BuildSignatureCall(symbols::BEGIN_FUNCTION_SIGNATURE, BB, F);
112 return BuildSignatureCall(symbols::END_FUNCTION_SIGNATURE, BB, F);
117 static std::string GetArgumentSymbolName(
Argument &Arg) {
132 GetArgumentSymbolName(Arg), FnType);
141 BuildBeginSignature(BB, F);
142 for (
Argument &Arg : F.
args()) { BuildArgument(BB, Arg); }
143 BuildEndSignature(BB, F);
147 static void BuildEntryBlock(
Function &F) {
152 "instrumentation_entry",
155 BuildSignature(*BB, F);
161 static std::string GetReturnSymbolName(
Value &Val) {
169 if (
auto *
Ret = dyn_cast<ReturnInst>(&I)) {
170 Value *RetVal =
Ret->getReturnValue();
171 assert(RetVal &&
"should only be instrumenting functions with return values");
177 GetReturnSymbolName(*RetVal), FnType);
185 static void BuildExitHooks(
Function &F) {
189 auto NBBI = std::next(BBI);
199 static bool ShouldInstrument(
Function &F) {
204 bool AVRInstrumentFunctions::runOnFunction(
Function &F) {
205 if (ShouldInstrument(F)) {
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
LLVM Argument representation.
Like Internal, but omit from symbol table.
Type * getReturnType() const
Returns the type of the ret val.
const Function * getParent() const
Return the enclosing method, or null if none.
static IntegerType * getInt16Ty(LLVMContext &C)
#define PREFIX(NAME, VALUE)
StringRef getName() const
Return a constant reference to the value's name.
iterator begin()
Instruction iterator methods.
Class to represent function types.
static GetElementPtrInst * CreateInBounds(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Create an "inbounds" getelementptr.
INITIALIZE_PASS(AVRInstrumentFunctions,"avr-instrument-functions", AVR_INSTRUMENT_FUNCTIONS_NAME, false, false) namespace llvm
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
void initializeAVRInstrumentFunctionsPass(PassRegistry &)
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeSet AttributeList)
Look up the specified function in the module symbol table.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
const Function * getParent() const
This is an important base class in LLVM.
static Type * getVoidTy(LLVMContext &C)
FunctionPass class - This class is used to implement most global optimizations.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Class to represent integer types.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static CallInst * Create(Value *Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
FunctionPass * createAVRInstrumentFunctionsPass()
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.
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
const BasicBlock & getEntryBlock() const
#define AVR_INSTRUMENT_FUNCTIONS_NAME
const std::string to_string(const T &Value)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVMContext & getContext() const
Get the context in which this basic block lives.
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
const ArgumentListType & getArgumentList() const
Get the underlying elements of the Function...
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
StringRef - Represent a constant reference to a string, i.e.
static IntegerType * getInt8Ty(LLVMContext &C)
const BasicBlock * getParent() const
iterator_range< arg_iterator > args()
bool isVoidTy() const
Return true if this is 'void'.