Skip to content

Commit

Permalink
remove svfvirtualcallinst
Browse files Browse the repository at this point in the history
  • Loading branch information
jumormt committed Oct 21, 2024
1 parent 045db84 commit d166710
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 97 deletions.
14 changes: 1 addition & 13 deletions svf-llvm/lib/LLVMModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,7 @@ void LLVMModuleSet::createSVFFunction(const Function* func)
SVFInstruction* svfInst = nullptr;
if (const CallBase* call = SVFUtil::dyn_cast<CallBase>(&inst))
{
if (cppUtil::isVirtualCallSite(call))
svfInst = new SVFVirtualCallInst(
getSVFType(call->getType()), svfBB,
call->getFunctionType()->isVarArg(),
inst.isTerminator());
else
svfInst = new SVFCallInst(
svfInst = new SVFCallInst(
getSVFType(call->getType()), svfBB,
call->getFunctionType()->isVarArg(),
inst.isTerminator());
Expand Down Expand Up @@ -379,12 +373,6 @@ void LLVMModuleSet::initSVFBasicBlock(const Function* func)
{
svfcall->setCalledOperand(getSVFValue(called_llvmval));
}
if(SVFVirtualCallInst* virtualCall = SVFUtil::dyn_cast<SVFVirtualCallInst>(svfcall))
{
virtualCall->setVtablePtr(getSVFValue(cppUtil::getVCallVtblPtr(call)));
virtualCall->setFunIdxInVtable(cppUtil::getVCallIdx(call));
virtualCall->setFunNameOfVirtualCall(cppUtil::getFunNameOfVCallSite(call));
}
for(u32_t i = 0; i < call->arg_size(); i++)
{
SVFValue* svfval = getSVFValue(call->getArgOperand(i));
Expand Down
3 changes: 0 additions & 3 deletions svf/include/SVFIR/SVFFileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ class SVFFunction;
class SVFBasicBlock;
class SVFInstruction;
class SVFCallInst;
class SVFVirtualCallInst;
class SVFConstant;
class SVFGlobalValue;
class SVFArgument;
Expand Down Expand Up @@ -516,7 +515,6 @@ class SVFIRWriter
cJSON* contentToJson(const SVFBasicBlock* value);
cJSON* contentToJson(const SVFInstruction* value);
cJSON* contentToJson(const SVFCallInst* value);
cJSON* contentToJson(const SVFVirtualCallInst* value);
cJSON* contentToJson(const SVFConstant* value);
cJSON* contentToJson(const SVFGlobalValue* value);
cJSON* contentToJson(const SVFArgument* value);
Expand Down Expand Up @@ -1290,7 +1288,6 @@ class SVFIRReader
void fill(const cJSON*& fieldJson, SVFBasicBlock* value);
void fill(const cJSON*& fieldJson, SVFInstruction* value);
void fill(const cJSON*& fieldJson, SVFCallInst* value);
void fill(const cJSON*& fieldJson, SVFVirtualCallInst* value);
void fill(const cJSON*& fieldJson, SVFConstant* value);
void fill(const cJSON*& fieldJson, SVFGlobalValue* value);
void fill(const cJSON*& fieldJson, SVFArgument* value);
Expand Down
60 changes: 0 additions & 60 deletions svf/include/SVFIR/SVFValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -735,66 +735,6 @@ class SVFCallInst : public SVFInstruction
}
};

class SVFVirtualCallInst : public SVFCallInst
{
friend class SVFIRWriter;
friend class SVFIRReader;
friend class LLVMModuleSet;

private:
const SVFValue* vCallVtblPtr; /// virtual table pointer
s32_t virtualFunIdx; /// virtual function index of the virtual table(s) at a virtual call
std::string funNameOfVcall; /// the function name of this virtual call

protected:
inline void setFunIdxInVtable(s32_t idx)
{
virtualFunIdx = idx;
}
inline void setFunNameOfVirtualCall(const std::string& name)
{
funNameOfVcall = name;
}
inline void setVtablePtr(const SVFValue* vptr)
{
vCallVtblPtr = vptr;
}

public:
SVFVirtualCallInst(const SVFType* ty, const SVFBasicBlock* b, bool vararg,
bool tm)
: SVFCallInst(ty, b, vararg, tm, SVFVCall), vCallVtblPtr(nullptr),
virtualFunIdx(-1), funNameOfVcall()
{
}
inline const SVFValue* getVtablePtr() const
{
assert(vCallVtblPtr && "virtual call does not have a vtblptr? set it first");
return vCallVtblPtr;
}
inline s32_t getFunIdxInVtable() const
{
assert(virtualFunIdx >=0 && "virtual function idx is less than 0? not set yet?");
return virtualFunIdx;
}
inline const std::string& getFunNameOfVirtualCall() const
{
return funNameOfVcall;
}
static inline bool classof(const SVFValue *node)
{
return node->getKind() == SVFVCall;
}
static inline bool classof(const SVFInstruction *node)
{
return node->getKind() == SVFVCall;
}
static inline bool classof(const SVFCallInst *node)
{
return node->getKind() == SVFVCall;
}
};

class SVFConstant : public SVFValue
{
friend class SVFIRWriter;
Expand Down
21 changes: 0 additions & 21 deletions svf/lib/SVFIR/SVFFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ static SVFValue* createSVFValue(SVFValue::GNodeK kind, const SVFType* type,
return new SVFInstruction(type, {}, {}, {});
case SVFValue::SVFCall:
return new SVFCallInst(type, {}, {}, {});
case SVFValue::SVFVCall:
return new SVFVirtualCallInst(type, {}, {}, {});
case SVFValue::SVFGlob:
return new SVFGlobalValue(type);
case SVFValue::SVFArg:
Expand Down Expand Up @@ -189,7 +187,6 @@ cJSON* SVFIRWriter::virtToJson(const SVFValue* value)
CASE(SVFBB, SVFBasicBlock);
CASE(SVFInst, SVFInstruction);
CASE(SVFCall, SVFCallInst);
CASE(SVFVCall, SVFVirtualCallInst);
CASE(SVFGlob, SVFGlobalValue);
CASE(SVFArg, SVFArgument);
CASE(SVFConst, SVFConstant);
Expand Down Expand Up @@ -578,15 +575,6 @@ cJSON* SVFIRWriter::contentToJson(const SVFCallInst* value)
return root;
}

cJSON* SVFIRWriter::contentToJson(const SVFVirtualCallInst* value)
{
cJSON* root = contentToJson(static_cast<const SVFCallInst*>(value));
JSON_WRITE_FIELD(root, value, vCallVtblPtr);
JSON_WRITE_FIELD(root, value, virtualFunIdx);
JSON_WRITE_FIELD(root, value, funNameOfVcall);
return root;
}

cJSON* SVFIRWriter::contentToJson(const SVFConstant* value)
{
return contentToJson(static_cast<const SVFValue*>(value));
Expand Down Expand Up @@ -2308,7 +2296,6 @@ void SVFIRReader::virtFill(const cJSON*& fieldJson, SVFValue* value)
CASE(SVFBB, SVFBasicBlock);
CASE(SVFInst, SVFInstruction);
CASE(SVFCall, SVFCallInst);
CASE(SVFVCall, SVFVirtualCallInst);
CASE(SVFGlob, SVFGlobalValue);
CASE(SVFArg, SVFArgument);
CASE(SVFConst, SVFConstant);
Expand Down Expand Up @@ -2373,14 +2360,6 @@ void SVFIRReader::fill(const cJSON*& fieldJson, SVFCallInst* value)
JSON_READ_FIELD_FWD(fieldJson, value, calledVal);
}

void SVFIRReader::fill(const cJSON*& fieldJson, SVFVirtualCallInst* value)
{
fill(fieldJson, static_cast<SVFCallInst*>(value));
JSON_READ_FIELD_FWD(fieldJson, value, vCallVtblPtr);
JSON_READ_FIELD_FWD(fieldJson, value, virtualFunIdx);
JSON_READ_FIELD_FWD(fieldJson, value, funNameOfVcall);
}

void SVFIRReader::fill(const cJSON*& fieldJson, SVFConstant* value)
{
fill(fieldJson, static_cast<SVFValue*>(value));
Expand Down

0 comments on commit d166710

Please sign in to comment.