Computer Laboratory

tesla::FnCallerInstrumenter Class Reference

Detailed Description

Instruments function calls in the caller context.

Definition at line 56 of file Caller.h.

#include "Caller.h"

+ Inheritance diagram for tesla::FnCallerInstrumenter:
+ Collaboration diagram for tesla::FnCallerInstrumenter:

Public Member Functions

 FnCallerInstrumenter (const Manifest &M, bool SuppressDI)
 
 ~FnCallerInstrumenter ()
 
const char * getPassName () const
 
virtual bool doInitialization (llvm::Module &M)
 
virtual bool runOnFunction (llvm::Function &Fn)
 
virtual bool runOnBasicBlock (llvm::BasicBlock &Block)
 
- Public Member Functions inherited from tesla::Instrumenter
 Instrumenter (const Manifest &M, bool SuppressDI)
 
virtual ~Instrumenter ()
 

Static Public Attributes

static char ID = 0
 

Additional Inherited Members

- Protected Attributes inherited from tesla::Instrumenter
const ManifestM
 TESLA manifest that describes automata. More...
 
const bool SuppressDebugInstr
 Don't produce debug instrumentation (e.g., printf() statements). More...
 

Constructor & Destructor Documentation

tesla::FnCallerInstrumenter::FnCallerInstrumenter ( const Manifest M,
bool  SuppressDI 
)
inline

Definition at line 59 of file Caller.h.

60  : Instrumenter(M, SuppressDI), FunctionPass(ID) {}
tesla::FnCallerInstrumenter::~FnCallerInstrumenter ( )

Definition at line 53 of file Caller.cpp.

53  {
54  ::google::protobuf::ShutdownProtobufLibrary();
55 }

Member Function Documentation

bool tesla::FnCallerInstrumenter::doInitialization ( llvm::Module &  M)
virtual

Definition at line 57 of file Caller.cpp.

References tesla::FnTransition::FnEvent().

57  {
58  bool ModifiedIR = true;
59 
60  for (auto i : M.RootAutomata()) {
61  auto& A = *M.FindAutomaton(i->identifier());
62  for (auto EquivClass : A) {
63  assert(!EquivClass.empty());
64 
65  auto *Head = dyn_cast<FnTransition>(*EquivClass.begin());
66  if (!Head)
67  continue;
68 
69  auto& FnEvent = Head->FnEvent();
70  if (FnEvent.context() != FunctionEvent::Caller)
71  continue;
72 
73  Function *Target = Mod.getFunction(FnEvent.function().name());
74  if (!Target)
75  continue;
76 
77  GetOrCreateInstr(Mod, Target, FnEvent.direction())
78  ->AppendInstrumentation(A, FnEvent, EquivClass);
79 
80  ModifiedIR = true;
81  }
82  }
83 
84  return ModifiedIR;
85 }

+ Here is the call graph for this function:

const char* tesla::FnCallerInstrumenter::getPassName ( ) const
inline

Definition at line 63 of file Caller.h.

63  {
64  return "TESLA function instrumenter (caller-side)";
65  }
bool tesla::FnCallerInstrumenter::runOnBasicBlock ( llvm::BasicBlock &  Block)
virtual

Definition at line 114 of file Caller.cpp.

References tesla::CallerInstrumentation::Instrument().

114  {
115  bool ModifiedIR = false;
116 
117  for (auto &Inst : Block) {
118  if (!isa<CallInst>(Inst)) continue;
119  CallInst &Call = cast<CallInst>(Inst);
120  Function *Callee = Call.getCalledFunction();
121 
122  // TODO: handle indirection (e.g. function pointers)?
123  if (!Callee)
124  continue;
125 
126  StringRef Name = Callee->getName();
127  if (auto Instr = Calls.lookup(Name))
128  ModifiedIR |= Instr->Instrument(Call);
129 
130  if (auto Instr = Returns.lookup(Name))
131  ModifiedIR |= Instr->Instrument(Call);
132  }
133 
134  return ModifiedIR;
135 }

+ Here is the call graph for this function:

bool tesla::FnCallerInstrumenter::runOnFunction ( llvm::Function &  Fn)
virtual

Definition at line 104 of file Caller.cpp.

104  {
105  bool modifiedIR = false;
106 
107  for (auto &Block : Fn) {
108  modifiedIR |= runOnBasicBlock(Block);
109  }
110 
111  return modifiedIR;
112 }

Member Data Documentation

char tesla::FnCallerInstrumenter::ID = 0
static

Definition at line 58 of file Caller.h.


The documentation for this class was generated from the following files: