Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] remove getPtrElement #1296

Merged
merged 4 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion svf-llvm/include/SVF-LLVM/LLVMUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ void viewCFGOnly(const Function* fun);
const ConstantStruct *getVtblStruct(const GlobalValue *vtbl);

bool isValVtbl(const Value* val);
bool isLoadVtblInst(const LoadInst* loadInst);
bool isVirtualCallSite(const CallBase* cs);
bool isConstructor(const Function* F);
bool isDestructor(const Function* F);
Expand Down
31 changes: 0 additions & 31 deletions svf-llvm/lib/LLVMUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,37 +962,6 @@ bool LLVMUtil::isValVtbl(const Value* val)
vtblLabelBeforeDemangle) == 0;
}

bool LLVMUtil::isLoadVtblInst(const LoadInst* loadInst)
{
const Value* loadSrc = loadInst->getPointerOperand();
const Type* valTy = loadSrc->getType();
const Type* elemTy = valTy;
for (u32_t i = 0; i < 3; ++i)
{
// TODO: getPtrElementType to be removed
if (const PointerType* ptrTy = SVFUtil::dyn_cast<PointerType>(elemTy))
elemTy = LLVMUtil::getPtrElementType(ptrTy);
else
return false;
}
if (const FunctionType* functy = SVFUtil::dyn_cast<FunctionType>(elemTy))
{
const Type* paramty = functy->getParamType(0);
std::string className = "";
if(const PointerType* ptrTy = SVFUtil::dyn_cast<PointerType>(paramty))
{
// TODO: getPtrElementType need type inference
if(const StructType* st = SVFUtil::dyn_cast<StructType>(getPtrElementType(ptrTy)))
className = LLVMUtil::getClassNameFromType(st);
}
if (className.size() > 0)
{
return true;
}
}
return false;
}

/*
* a virtual callsite follows the following instruction sequence pattern:
* %vtable = load this
Expand Down
15 changes: 3 additions & 12 deletions svf/lib/MemoryModel/AccessPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,16 @@

/// Return element number of a type
/// (1) StructType or Array, return flattened number elements.
/// (2) PointerType, return the element number of the pointee
/// (3) non-pointer SingleValueType, return 1
/// (2) non-pointer SingleValueType, return 1
u32_t AccessPath::getElementNum(const SVFType* type) const
{
assert(!SVFUtil::isa<SVFPointerType>(type) && "can't be pointer type");

Check warning on line 64 in svf/lib/MemoryModel/AccessPath.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/MemoryModel/AccessPath.cpp#L64

Added line #L64 was not covered by tests

if (SVFUtil::isa<SVFArrayType, SVFStructType>(type))
{
return SymbolTableInfo::SymbolInfo()->getNumOfFlattenElements(type);
}
else if (type->isSingleValueType())
{
/// This is a pointer arithmetic
// TODO: getPtrElementType to be removed
if(const SVFPointerType* pty = SVFUtil::dyn_cast<SVFPointerType>(type))
return getElementNum(pty->getPtrElementType());
else
return 1;
}
else if (SVFUtil::isa<SVFFunctionType>(type))
else if (type->isSingleValueType() || SVFUtil::isa<SVFFunctionType>(type))

Check warning on line 70 in svf/lib/MemoryModel/AccessPath.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/MemoryModel/AccessPath.cpp#L70

Added line #L70 was not covered by tests
{
return 1;
}
Expand Down
3 changes: 0 additions & 3 deletions svf/lib/MemoryModel/PointerAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,6 @@ void PointerAnalysis::dumpAllTypes()

const SVFType* type = node->getValue()->getType();
pag->getSymbolInfo()->printFlattenFields(type);
// TODO: getPtrElementType to be removed
if (const SVFPointerType* ptType = SVFUtil::dyn_cast<SVFPointerType>(type))
pag->getSymbolInfo()->printFlattenFields(ptType->getPtrElementType());
}
}

Expand Down
3 changes: 1 addition & 2 deletions svf/lib/SVFIR/SVFType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

void SVFPointerType::print(std::ostream& os) const
{
// TODO: getPtrElementType to be removed
os << *getPtrElementType() << '*';
os << *ptrElementType << '*';

Check warning on line 23 in svf/lib/SVFIR/SVFType.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/SVFIR/SVFType.cpp#L23

Added line #L23 was not covered by tests
}

void SVFIntegerType::print(std::ostream& os) const
Expand Down
6 changes: 1 addition & 5 deletions svf/lib/SVFIR/SymbolTableInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,7 @@
}
else if (const SVFPointerType* pt= SVFUtil::dyn_cast<SVFPointerType>(type))
{
// TODO: getPtrElementType to be removed
u32_t eSize = getNumOfFlattenElements(pt->getPtrElementType());
outs() << " {Type: " << *pt << "}\n"
<< "\t [target size = " << eSize << "]\n"
<< "\n";
outs() << *pt << "\n";

Check warning on line 261 in svf/lib/SVFIR/SymbolTableInfo.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/SVFIR/SymbolTableInfo.cpp#L261

Added line #L261 was not covered by tests
}
else if (const SVFFunctionType* fu =
SVFUtil::dyn_cast<SVFFunctionType>(type))
Expand Down
Loading