From 5fc789b2f40f66a989d49c92fe98df72e9e1e18d Mon Sep 17 00:00:00 2001 From: jumormt Date: Wed, 6 Dec 2023 13:27:18 +1100 Subject: [PATCH] rename sourceElementType, fix computeConstantOffset bug --- svf/include/MemoryModel/AccessPath.h | 14 +++++++------- svf/lib/MemoryModel/AccessPath.cpp | 8 +------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/svf/include/MemoryModel/AccessPath.h b/svf/include/MemoryModel/AccessPath.h index a9a678e1f..7393803e3 100644 --- a/svf/include/MemoryModel/AccessPath.h +++ b/svf/include/MemoryModel/AccessPath.h @@ -65,13 +65,13 @@ class AccessPath typedef std::vector 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()) { } @@ -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; } //@} @@ -109,9 +109,9 @@ class AccessPath { return idxOperandPairs; } - inline const SVFType* getGepSourceElementType() const + inline const SVFType* getGepPointeeType() const { - return gepSourceElementType; + return gepPointeeType; } //@} @@ -173,7 +173,7 @@ class AccessPath APOffset fldIdx; ///< Accumulated Constant Offsets IdxOperandPairs idxOperandPairs; ///< a vector of actual offset in the form of - 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 }; diff --git a/svf/lib/MemoryModel/AccessPath.cpp b/svf/lib/MemoryModel/AccessPath.cpp index f508bdf99..990947a54 100644 --- a/svf/lib/MemoryModel/AccessPath.cpp +++ b/svf/lib/MemoryModel/AccessPath.cpp @@ -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--) { @@ -238,8 +234,6 @@ APOffset AccessPath::computeConstantOffset() const offset); totalConstOffset += flattenOffset; } - else - totalConstOffset += offset; } } return totalConstOffset; @@ -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())