Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions lib/InstModel/LFCPAInstModel/LFCPAInstModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ std::vector<Token *> LFCPAInstModel::extractToken(llvm::CmpInst *Inst) {
// llvm::errs()<<"\n VALUE= "<<*v;

I = llvm::dyn_cast<llvm::Instruction>(v);
q.push(I);

if(I != nullptr){
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Segmentation fault as I was sometimes a null pointer.

q.push(I);
}

while(!q.empty()) {
llvm::Instruction *I = q.front();
Expand All @@ -205,7 +206,9 @@ std::vector<Token *> LFCPAInstModel::extractToken(llvm::CmpInst *Inst) {
llvm::Value* v = U.get();
// llvm::errs()<<"\n VALUE= "<<*v;
llvm::Instruction *I1 = llvm::dyn_cast<llvm::Instruction>(v);
q.push(I1);
if(I != nullptr){
q.push(I1);
}
}
}
}//end if load
Expand Down Expand Up @@ -262,6 +265,14 @@ std::vector<Token *> LFCPAInstModel::extractToken(llvm::ReturnInst *Inst) {
Ins = I;
}//end else
}//end if load
else if(llvm::BitCastInst *BI = llvm::dyn_cast<llvm::BitCastInst>(I)){
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getting an infinite loop as bitcast was not supported in return.

Ins = I;
InstInfoMap[I] = II;
}
else {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getting infinite loop as other instructions are not supported right now.

skipFlag = true;
break;
}
}//end for
}//end while
}//end if
Expand All @@ -285,6 +296,18 @@ std::vector<Token *> LFCPAInstModel::extractToken(llvm::BitCastInst *Inst) {
} else if (llvm::BitCastInst *BI =
llvm::dyn_cast<llvm::BitCastInst>(Inst->getOperand(0))) {
TokenVec.push_back(this->getTokenWrapper()->getToken(BI->getDestTy()));
} else if(llvm::LoadInst *LI = llvm::dyn_cast<llvm::LoadInst>(Inst->getOperand(0))) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handling one or more load instruction before bitcast.

Token* TokLIOp = this->getTokenWrapper()->getToken(LI->getPointerOperand());
if(!TokLIOp->isGlobalVar()) {
if(llvm::LoadInst* LIOp = llvm::dyn_cast<llvm::LoadInst>(LI->getPointerOperand())) {
std::vector<Token*> LITokens = this->extractToken(LIOp);
if(LITokens.size()==2) {
TokenVec.push_back(LITokens[1]);
}
}
} else {
TokenVec.push_back(this->getTokenWrapper()->getToken(LI->getPointerOperand()));
}
}
if (TokenVec.size() == 1) {
TokenVec.push_back(this->getTokenWrapper()->getToken(Inst->getOperand(0)));
Expand Down