Skip to content

Commit

Permalink
fix saber
Browse files Browse the repository at this point in the history
  • Loading branch information
bjjwwang committed Dec 11, 2024
1 parent a3365f2 commit 22045d8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion svf-llvm/include/SVF-LLVM/SVFIRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class SVFIRBuilder: public llvm::InstVisitor<SVFIRBuilder>
{
LLVMContext& cxt = llvmModuleSet()->getContext();
ConstantPointerNull* constNull = ConstantPointerNull::get(PointerType::getUnqual(cxt));
NodeID nullPtr = pag->addValNode(llvmModuleSet()->getSVFValue(constNull),pag->getNullPtr(), nullptr);
NodeID nullPtr = pag->addConstantNullPtrValNode(llvmModuleSet()->getSVFValue(constNull),pag->getNullPtr(), nullptr);
setCurrentLocation(constNull, nullptr);
addBlackHoleAddrEdge(pag->getBlkPtr());
return nullPtr;
Expand Down
15 changes: 11 additions & 4 deletions svf/lib/MemoryModel/PointerAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,17 @@ void PointerAnalysis::getVFnsFromPts(const CallICFGNode* cs, const PointsTo &tar
const PAGNode *ptdnode = pag->getGNode(*it);
if (ptdnode->hasValue())
{
if (const SVFGlobalValue *vtbl = SVFUtil::dyn_cast<SVFGlobalValue>(ptdnode->getValue()))
{
if (chaVtbls.find(vtbl) != chaVtbls.end())
vtbls.insert(vtbl);
// ptd is global obj var or ptd's base is global obj var
if (const GlobalValueObjVar *global_vtbl = SVFUtil::dyn_cast<GlobalValueObjVar>(ptdnode)) {
const SVFGlobalValue* globalValue = SVFUtil::dyn_cast<SVFGlobalValue>(global_vtbl->getValue());
if (chaVtbls.find(globalValue) != chaVtbls.end())
vtbls.insert(globalValue);
} else if (const GepObjVar *gep_vtbl = SVFUtil::dyn_cast<GepObjVar>(ptdnode)) {
if (SVFUtil::isa<GlobalValueObjVar>(pag->getGNode(gep_vtbl->getBaseNode()))) {
const SVFGlobalValue* globalValue = SVFUtil::dyn_cast<SVFGlobalValue>(gep_vtbl->getValue());
if (chaVtbls.find(globalValue) != chaVtbls.end())
vtbls.insert(globalValue);
}
}
}
}
Expand Down
20 changes: 14 additions & 6 deletions svf/lib/SABER/SaberCondAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,27 +399,35 @@ bool SaberCondAllocator::isTestNotNullExpr(const ICFGNode* test) const
bool SaberCondAllocator::isTestContainsNullAndTheValue(const CmpStmt *cmp) const
{

const SVFValue* op0 = cmp->getOpVar(0)->getValue();
const SVFValue* op1 = cmp->getOpVar(1)->getValue();
if (SVFUtil::isa<SVFConstantNullPtr>(op1))
const SVFVar* op0 = cmp->getOpVar(0);
const SVFVar* op1 = cmp->getOpVar(1);
bool a = SVFUtil::dyn_cast<ConstantNullPtrValVar>(op0) ||
SVFUtil::dyn_cast<ConstantNullPtrObjVar>(op0);
bool b = SVFUtil::dyn_cast<ConstantNullPtrValVar>(op1) ||
SVFUtil::dyn_cast<ConstantNullPtrObjVar>(op1);
bool c = SVFUtil::dyn_cast<SVFConstantNullPtr>(op0->getValue());
bool d = SVFUtil::dyn_cast<SVFConstantNullPtr>(op1->getValue());
assert(a == c);
assert(b == d);
if (SVFUtil::isa<ConstantNullPtrValVar, ConstantNullPtrObjVar>(op1))
{
Set<const SVFValue* > inDirVal;
inDirVal.insert(getCurEvalSVFGNode()->getValue());
for (const auto &it: getCurEvalSVFGNode()->getOutEdges())
{
inDirVal.insert(it->getDstNode()->getValue());
}
return inDirVal.find(op0) != inDirVal.end();
return inDirVal.find(op0->getValue()) != inDirVal.end();
}
else if (SVFUtil::isa<SVFConstantNullPtr>(op0))
else if (SVFUtil::isa<ConstantNullPtrValVar, ConstantNullPtrObjVar>(op0))
{
Set<const SVFValue* > inDirVal;
inDirVal.insert(getCurEvalSVFGNode()->getValue());
for (const auto &it: getCurEvalSVFGNode()->getOutEdges())
{
inDirVal.insert(it->getDstNode()->getValue());
}
return inDirVal.find(op1) != inDirVal.end();
return inDirVal.find(op1->getValue()) != inDirVal.end();
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion svf/lib/SABER/SaberSVFGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void SaberSVFGBuilder::collectGlobals(BVDataPTAImpl* pta)
if(SVFUtil::isa<DummyObjVar>(pag->getGNode(gepobj->getBaseNode())))
continue;
}
if(pagNode->hasValue() && SVFUtil::isa<SVFGlobalValue>(pagNode->getValue()))
if(pagNode->hasValue() && SVFUtil::isa<GlobalValueValvar, GlobalValueObjVar>(pagNode))
worklist.push_back(it->first);
}

Expand Down

0 comments on commit 22045d8

Please sign in to comment.