#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
#include "llvm/GlobalVariable.h"
-#include "llvm/Constants.h"//llvm/ConstantVals.h"
+#include "llvm/Constants.h"
#include "llvm/BasicBlock.h"
#include "llvm/Function.h"
#include <string.h>
void getTriggerCode(Module *M, BasicBlock *BB, int MethNo, Value *pathNo,
- Value *cnt){
- // return;
- //cerr<<"In trigger code"<<endl;
+ Value *cnt){
static int i=-1;
i++;
char gstr[100];
std::string globalVarName=gstr;
SymbolTable *ST = M->getSymbolTable();
vector<const Type*> args;
- args.push_back(PointerType::get(Type::SByteTy));
+ //args.push_back(PointerType::get(Type::SByteTy));
args.push_back(Type::IntTy);
args.push_back(Type::IntTy);
args.push_back(Type::IntTy);
vector<Value *> trargs;
//pred_iterator piter=BB->pred_begin();
- std::string predName=BB->getName();
- Constant *bbName=ConstantArray::get(predName);//BB->getName());
- GlobalVariable *gbl=new GlobalVariable(ArrayType::get(Type::SByteTy,
- predName.size()+1),
- true, true, bbName, gstr);
- M->getGlobalList().push_back(gbl);
+ //std::string predName = "uu";//BB->getName();
+ //Constant *bbName=ConstantArray::get(predName);//BB->getName());
+ //GlobalVariable *gbl=new GlobalVariable(ArrayType::get(Type::SByteTy,
+ // predName.size()+1),
+ // true, true, bbName, gstr);
+
+ //M->getGlobalList().push_back(gbl);
vector<Value *> elargs;
elargs.push_back(ConstantUInt::get(Type::UIntTy, 0));
elargs.push_back(ConstantUInt::get(Type::UIntTy, 0));
- Instruction *getElmntInst=new GetElementPtrInst(gbl,elargs,"elmntInst");
-
+ // commented out bb name frm which its called
+ //Instruction *getElmntInst=new GetElementPtrInst(gbl,elargs,"elmntInst");
+
//trargs.push_back(ConstantArray::get(BB->getName()));
- trargs.push_back(getElmntInst);
+
+ //trargs.push_back(getElmntInst);
+ //trargs.push_back(bbName);
+
trargs.push_back(ConstantSInt::get(Type::IntTy,MethNo));
//trargs.push_back(ConstantSInt::get(Type::IntTy,-1));//erase this
BasicBlock::InstListType& instList=BB->getInstList();
BasicBlock::iterator here=instList.begin();
- here = ++instList.insert(here, getElmntInst);
+ //here = ++instList.insert(here, getElmntInst);
instList.insert(here,callInst);
- //}
- //else{
- //insert trigger method
-
- //assert(0&&"No method trigger");
- //}
}
//Is terminator a branch instruction?
//then we need to change branch destinations to include new BB
- BranchInst *BI=cast<BranchInst>(TI);
-
+ //std::cerr<<"before cast!\n";
+ BranchInst *BI = cast<BranchInst>(TI);
+
if(BI->isUnconditional()){
BI->setUnconditionalDest(newBB);
Instruction *newBI2=new BranchInst(BB2);
newBB->getInstList().push_back(newBI2);
}
+ //std::cerr<<"After casting\n";
//get code for the new BB
//now iterate over BB2, and set its Phi nodes right
for(BasicBlock::iterator BB2Inst = BB2->begin(), BBend = BB2->end();