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

rename getConstantFldIdx to getConstantStructFldIdx #1268

Merged
merged 1 commit into from
Dec 4, 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
4 changes: 2 additions & 2 deletions svf-llvm/lib/SVFIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,15 @@ bool SVFIRBuilder::computeGepOffset(const User *V, AccessPath& ap)
continue;
APOffset idx = op->getSExtValue();
u32_t offset = pag->getSymbolInfo()->getFlattenedElemIdx(LLVMModuleSet::getLLVMModuleSet()->getSVFType(arrTy), idx);
ap.setFldIdx(ap.getConstantFieldIdx() + offset);
ap.setFldIdx(ap.getConstantStructFldIdx() + offset);
}
else if (const StructType *ST = SVFUtil::dyn_cast<StructType>(gepTy))
{
assert(op && "non-const offset accessing a struct");
//The actual index
APOffset idx = op->getSExtValue();
u32_t offset = pag->getSymbolInfo()->getFlattenedElemIdx(LLVMModuleSet::getLLVMModuleSet()->getSVFType(ST), idx);
ap.setFldIdx(ap.getConstantFieldIdx() + offset);
ap.setFldIdx(ap.getConstantStructFldIdx() + offset);
}
else if (gepTy->isSingleValueType())
{
Expand Down
12 changes: 7 additions & 5 deletions svf-llvm/lib/SVFIRExtAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ void SVFIRBuilder::addComplexConsForExt(Value *D, Value *S, const Value* szValue
{
LLVMModuleSet* llvmmodule = LLVMModuleSet::getLLVMModuleSet();
const SVFType* dElementType = pag->getSymbolInfo()->getFlatternedElemType(llvmmodule->getSVFType(dtype),
fields[index].getConstantFieldIdx());
fields[index].getConstantStructFldIdx());
const SVFType* sElementType = pag->getSymbolInfo()->getFlatternedElemType(llvmmodule->getSVFType(stype),
fields[index].getConstantFieldIdx());
fields[index].getConstantStructFldIdx());
NodeID dField = getGepValVar(D,fields[index],dElementType);
NodeID sField = getGepValVar(S,fields[index],sElementType);
NodeID dummy = pag->addDummyValNode();
Expand Down Expand Up @@ -180,7 +180,8 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
for (u32_t index = 0; index < sz; index++)
{
LLVMModuleSet* llvmmodule = LLVMModuleSet::getLLVMModuleSet();
const SVFType* dElementType = pag->getSymbolInfo()->getFlatternedElemType(llvmmodule->getSVFType(dtype), dstFields[index].getConstantFieldIdx());
const SVFType* dElementType = pag->getSymbolInfo()->getFlatternedElemType(llvmmodule->getSVFType(dtype),
dstFields[index].getConstantStructFldIdx());
NodeID dField = getGepValVar(cs->getArgOperand(0), dstFields[index], dElementType);
addStoreEdge(getValueNode(cs->getArgOperand(1)),dField);
}
Expand Down Expand Up @@ -233,7 +234,8 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
// We have vArg3 points to the entry of _Rb_tree_node_base { color; parent; left; right; }.
// Now we calculate the offset from base to vArg3
NodeID vnArg3 = pag->getValueNode(svfCall->getArgOperand(3));
APOffset offset = getAccessPathFromBaseNode(vnArg3).getConstantFieldIdx();
APOffset offset =
getAccessPathFromBaseNode(vnArg3).getConstantStructFldIdx();

// We get all flattened fields of base
vector<AccessPath> fields = pag->getTypeLocSetsMap(vnArg3).second;
Expand All @@ -245,7 +247,7 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
if((u32_t)i >= fields.size())
break;
const SVFType* elementType = pag->getSymbolInfo()->getFlatternedElemType(pag->getTypeLocSetsMap(vnArg3).first,
fields[i].getConstantFieldIdx());
fields[i].getConstantStructFldIdx());
NodeID vnD = getGepValVar(cs->getArgOperand(3), fields[i], elementType);
NodeID vnS = pag->getValueNode(svfCall->getArgOperand(1));
if(vnD && vnS)
Expand Down
2 changes: 1 addition & 1 deletion svf/include/Graphs/ConsGEdge.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class NormalGepCGEdge : public GepCGEdge
/// Get location set of the gep edge
inline APOffset getConstantFieldIdx() const
{
return ap.getConstantFieldIdx();
return ap.getConstantStructFldIdx();
}

};
Expand Down
4 changes: 2 additions & 2 deletions svf/include/MemoryModel/AccessPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class AccessPath

/// Get methods
//@{
inline APOffset getConstantFieldIdx() const
inline APOffset getConstantStructFldIdx() const
{
return fldIdx;
}
Expand Down Expand Up @@ -177,7 +177,7 @@ template <> struct std::hash<SVF::AccessPath>
{
SVF::Hash<std::pair<SVF::NodeID, SVF::NodeID>> h;
std::hash<SVF::AccessPath::IdxOperandPairs> v;
return h(std::make_pair(ap.getConstantFieldIdx(),
return h(std::make_pair(ap.getConstantStructFldIdx(),
v(ap.getIdxOperandPairVec())));
}
};
Expand Down
4 changes: 2 additions & 2 deletions svf/include/SVFIR/SVFStatements.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,10 @@ class GepStmt: public AssignStmt
return getAccessPath().computeConstantOffset();
}
/// Field index of the gep statement if it access the field of a struct
inline APOffset getConstantFieldIdx() const
inline APOffset getConstantStructFldIdx() const
{
assert(isVariantFieldGep()==false && "Can't retrieve the AccessPath if using a variable field index (pointer arithmetic) for struct field access ");
return getAccessPath().getConstantFieldIdx();
return getAccessPath().getConstantStructFldIdx();
}
/// Gep statement with a variant field index (pointer arithmetic) for struct field access
inline bool isVariantFieldGep() const
Expand Down
2 changes: 1 addition & 1 deletion svf/include/SVFIR/SVFVariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ class GepValVar: public ValVar
/// offset of the base value variable
inline APOffset getConstantFieldIdx() const
{
return ap.getConstantFieldIdx();
return ap.getConstantStructFldIdx();
}

/// Return name of a LLVM value
Expand Down
3 changes: 2 additions & 1 deletion svf/lib/AbstractExecution/SVFIR2ConsExeState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,8 @@ std::pair<s32_t, s32_t> SVFIR2ConsExeState::getGepOffset(const SVF::GepStmt *gep
{
/// for instant constant index, e.g. gep arr, 1
if (gep->getOffsetVarAndGepTypePairVec().empty())
return std::make_pair(gep->getConstantFieldIdx(), gep->getConstantFieldIdx());
return std::make_pair(gep->getConstantStructFldIdx(),
gep->getConstantStructFldIdx());

s32_t totalOffset = 0;
/// default value of MaxFieldLimit is 512
Expand Down
4 changes: 4 additions & 0 deletions svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ SVFIR2ItvExeState::Addrs SVFIR2ItvExeState::getGepObjAddress(u32_t pointer, APOf
*/
IntervalValue SVFIR2ItvExeState::getByteOffset(const GepStmt *gep)
{
if (gep->isConstantOffset())
return IntervalValue((s64_t)gep->accumulateConstantByteOffset());
IntervalValue res(0); // Initialize the result interval 'res' to 0.
// Loop through the offsetVarAndGepTypePairVec in reverse order.
for (int i = gep->getOffsetVarAndGepTypePairVec().size() - 1; i >= 0; i--)
Expand Down Expand Up @@ -337,6 +339,8 @@ IntervalValue SVFIR2ItvExeState::getByteOffset(const GepStmt *gep)
*/
IntervalValue SVFIR2ItvExeState::getItvOfFlattenedElemIndex(const GepStmt *gep)
{
if (gep->isConstantOffset())
return IntervalValue((s64_t)gep->accumulateConstantOffset());
IntervalValue res(0);
for (int i = gep->getOffsetVarAndGepTypePairVec().size() - 1; i >= 0; i--)
{
Expand Down
3 changes: 2 additions & 1 deletion svf/lib/DDA/ContextDDA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ CxtPtSet ContextDDA::processGepPts(const GepSVFGNode* gep, const CxtPtSet& srcPt
}
else
{
CxtVar var(ptd.get_cond(),getGepObjVar(ptd.get_id(),gepStmt->getAccessPath().getConstantFieldIdx()));
CxtVar var(ptd.get_cond(),getGepObjVar(ptd.get_id(),
gepStmt->getAccessPath().getConstantStructFldIdx()));
tmpDstPts.set(var);
}
}
Expand Down
2 changes: 1 addition & 1 deletion svf/lib/DDA/FlowDDA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ PointsTo FlowDDA::processGepPts(const GepSVFGNode* gep, const PointsTo& srcPts)
}
else
{
NodeID fieldSrcPtdNode = getGepObjVar(ptd, gepStmt->getAccessPath().getConstantFieldIdx());
NodeID fieldSrcPtdNode = getGepObjVar(ptd, gepStmt->getAccessPath().getConstantStructFldIdx());
tmpDstPts.set(fieldSrcPtdNode);
}
}
Expand Down
8 changes: 4 additions & 4 deletions svf/lib/MemoryModel/AccessPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ APOffset AccessPath::computeConstantOffset() const
assert(isConstantOffset() && "not a constant offset");

if(idxOperandPairs.empty())
return getConstantFieldIdx();
return getConstantStructFldIdx();

APOffset totalConstOffset = 0;
for(int i = idxOperandPairs.size() - 1; i >= 0; i--)
Expand Down Expand Up @@ -249,14 +249,14 @@ APOffset AccessPath::computeConstantOffset() const
NodeBS AccessPath::computeAllLocations() const
{
NodeBS result;
result.set(getConstantFieldIdx());
result.set(getConstantStructFldIdx());
return result;
}

AccessPath AccessPath::operator+(const AccessPath& rhs) const
{
AccessPath ap(rhs);
ap.fldIdx += getConstantFieldIdx();
ap.fldIdx += getConstantStructFldIdx();
for (auto &p : ap.getIdxOperandPairVec())
ap.addOffsetVarAndGepTypePair(p.first, p.second);

Expand Down Expand Up @@ -314,7 +314,7 @@ std::string AccessPath::dump() const
std::string str;
std::stringstream rawstr(str);

rawstr << "AccessPath\tField_Index: " << getConstantFieldIdx();
rawstr << "AccessPath\tField_Index: " << getConstantStructFldIdx();
rawstr << ",\tNum-Stride: {";
const IdxOperandPairs& vec = getIdxOperandPairVec();
IdxOperandPairs::const_iterator it = vec.begin();
Expand Down
2 changes: 1 addition & 1 deletion svf/lib/SVFIR/SVFIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ void SVFIR::print()
outs() << (*iter)->getSrcID() << " -- VariantGep --> "
<< (*iter)->getDstID() << "\n";
else
outs() << gep->getRHSVarID() << " -- Gep (" << gep->getConstantFieldIdx()
outs() << gep->getRHSVarID() << " -- Gep (" << gep->getConstantStructFldIdx()
<< ") --> " << gep->getLHSVarID() << "\n";
}

Expand Down
2 changes: 1 addition & 1 deletion svf/lib/WPA/Andersen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ bool Andersen::processGepPts(const PointsTo& pts, const GepCGEdge* edge)
continue;
}

NodeID fieldSrcPtdNode = consCG->getGepObjVar(o, normalGepEdge->getAccessPath().getConstantFieldIdx());
NodeID fieldSrcPtdNode = consCG->getGepObjVar(o, normalGepEdge->getAccessPath().getConstantStructFldIdx());
tmpDstPts.set(fieldSrcPtdNode);
}
}
Expand Down
2 changes: 1 addition & 1 deletion svf/lib/WPA/FlowSensitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ bool FlowSensitive::processGep(const GepSVFGNode* edge)
continue;
}

NodeID fieldSrcPtdNode = getGepObjVar(o, gepStmt->getAccessPath().getConstantFieldIdx());
NodeID fieldSrcPtdNode = getGepObjVar(o, gepStmt->getAccessPath().getConstantStructFldIdx());
tmpDstPts.set(fieldSrcPtdNode);
}
}
Expand Down