Skip to content

Commit

Permalink
Remove "STATIC" annotation in extapi.bc (SVF-tools#1188)
Browse files Browse the repository at this point in the history
* Remove "STATIC" annotation in extapi.bc

* Return "STATIC_OBJECT" in an external function which has a static var that its return value points to

* Move the functions with annotations to the front of the functions without annotations in extapi.c

* annotate fdopen() with "ALLOC_RET"
  • Loading branch information
shuangxiangkan authored and JasonZhongZexin committed Sep 13, 2023
1 parent 6aebb82 commit 6b5caea
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 349 deletions.
4 changes: 2 additions & 2 deletions svf-llvm/include/SVF-LLVM/LLVMUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ inline const PointerType *getRefTypeOfHeapAllocOrStatic(const CallBase* cs)
if (const PointerType *argType = SVFUtil::dyn_cast<PointerType>(arg->getType()))
refType = SVFUtil::dyn_cast<PointerType>(getPtrElementType(argType));
}
// Case 2: heap/static object held by return value.
// Case 2: heap object held by return value.
else
{
assert((SVFUtil::isStaticExtCall(svfcs) || SVFUtil::isHeapAllocExtCallViaRet(svfcs))
assert(SVFUtil::isHeapAllocExtCallViaRet(svfcs)
&& "Must be heap alloc via ret, or static allocation site");
refType = SVFUtil::dyn_cast<PointerType>(cs->getType());
}
Expand Down
2 changes: 0 additions & 2 deletions svf-llvm/lib/LLVMUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ const std::string structName = "struct.";
*/
bool LLVMUtil::isObject(const Value* ref)
{
if (SVFUtil::isa<Instruction>(ref) && SVFUtil::isStaticExtCall(LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(SVFUtil::cast<Instruction>(ref))) )
return true;
if (SVFUtil::isa<Instruction>(ref) && SVFUtil::isHeapAllocExtCallViaRet(LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(SVFUtil::cast<Instruction>(ref))))
return true;
if (SVFUtil::isa<GlobalVariable>(ref))
Expand Down
2 changes: 1 addition & 1 deletion svf-llvm/lib/SVFIRExtAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
const SVFInstruction* svfInst = LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(cs);
const SVFCallInst* svfCall = SVFUtil::cast<SVFCallInst>(svfInst);

if (isHeapAllocExtCallViaRet(svfCall) || isStaticExtCall(svfCall))
if (isHeapAllocExtCallViaRet(svfCall))
{
NodeID val = pag->getValueNode(svfInst);
NodeID obj = pag->getObjectNode(svfInst);
Expand Down
9 changes: 0 additions & 9 deletions svf-llvm/lib/SymbolTableBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,15 +750,6 @@ void SymbolTableBuilder::initTypeInfo(ObjTypeInfo* typeinfo, const Value* val,
// Heap object, label its field as infinite here
objSize = typeinfo->getMaxFieldOffsetLimit();
}
else if (SVFUtil::isa<Instruction>(val) &&
isStaticExtCall(
LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(
SVFUtil::cast<Instruction>(val))))
{
analyzeStaticObjType(typeinfo,val);
// static object allocated before main, label its field as infinite here
objSize = typeinfo->getMaxFieldOffsetLimit();
}
else if(ArgInProgEntryFunction(val))
{
analyzeStaticObjType(typeinfo,val);
Expand Down
Loading

0 comments on commit 6b5caea

Please sign in to comment.