Skip to content

Commit

Permalink
Merge pull request #1271 from jumormt/12.6
Browse files Browse the repository at this point in the history
rename sourceElementType, fix computeConstantOffset bug
  • Loading branch information
yuleisui authored Dec 6, 2023
2 parents 99300ce + 5fc789b commit 1ec4620
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
14 changes: 7 additions & 7 deletions svf/include/MemoryModel/AccessPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ class AccessPath
typedef std::vector<IdxOperandPair> IdxOperandPairs;

/// Constructor
AccessPath(APOffset o = 0, const SVFType* srcTy = nullptr) : fldIdx(o), gepSourceElementType(srcTy) {}
AccessPath(APOffset o = 0, const SVFType* srcTy = nullptr) : fldIdx(o), gepPointeeType(srcTy) {}

/// Copy Constructor
AccessPath(const AccessPath& ap)
: fldIdx(ap.fldIdx),
idxOperandPairs(ap.getIdxOperandPairVec()),
gepSourceElementType(ap.getGepSourceElementType())
gepPointeeType(ap.getGepPointeeType())
{
}

Expand All @@ -85,13 +85,13 @@ class AccessPath
{
fldIdx = rhs.fldIdx;
idxOperandPairs = rhs.getIdxOperandPairVec();
gepSourceElementType = rhs.gepSourceElementType;
gepPointeeType = rhs.gepPointeeType;
return *this;
}
inline bool operator==(const AccessPath& rhs) const
{
return this->fldIdx == rhs.fldIdx &&
this->idxOperandPairs == rhs.idxOperandPairs && this->gepSourceElementType == rhs.gepSourceElementType;
this->idxOperandPairs == rhs.idxOperandPairs && this->gepPointeeType == rhs.gepPointeeType;
}
//@}

Expand All @@ -109,9 +109,9 @@ class AccessPath
{
return idxOperandPairs;
}
inline const SVFType* getGepSourceElementType() const
inline const SVFType* getGepPointeeType() const
{
return gepSourceElementType;
return gepPointeeType;
}
//@}

Expand Down Expand Up @@ -173,7 +173,7 @@ class AccessPath

APOffset fldIdx; ///< Accumulated Constant Offsets
IdxOperandPairs idxOperandPairs; ///< a vector of actual offset in the form of <SVF Var, iterator type>
const SVFType* gepSourceElementType; /// source element type in gep instruction,
const SVFType* gepPointeeType; /// source element type in gep instruction,
/// e.g., %f1 = getelementptr inbounds %struct.MyStruct, %struct.MyStruct* %arrayidx, i32 0, i32 0
/// the source element type is %struct.MyStruct
};
Expand Down
8 changes: 1 addition & 7 deletions svf/lib/MemoryModel/AccessPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,6 @@ APOffset AccessPath::computeConstantOffset() const

assert(isConstantOffset() && "not a constant offset");

// source element type is struct
if(gepSourceElementType && gepSourceElementType->isStructTy())
return getConstantStructFldIdx();

APOffset totalConstOffset = 0;
for(int i = idxOperandPairs.size() - 1; i >= 0; i--)
{
Expand All @@ -238,8 +234,6 @@ APOffset AccessPath::computeConstantOffset() const
offset);
totalConstOffset += flattenOffset;
}
else
totalConstOffset += offset;
}
}
return totalConstOffset;
Expand All @@ -256,7 +250,7 @@ NodeBS AccessPath::computeAllLocations() const

AccessPath AccessPath::operator+(const AccessPath& rhs) const
{
assert(gepSourceElementType == rhs.getGepSourceElementType() && "source element type not match");
assert(gepPointeeType == rhs.getGepPointeeType() && "source element type not match");
AccessPath ap(rhs);
ap.fldIdx += getConstantStructFldIdx();
for (auto &p : ap.getIdxOperandPairVec())
Expand Down

0 comments on commit 1ec4620

Please sign in to comment.