Skip to content

Commit 93446f6

Browse files
committed
Made VersionedFlowSensitive read-only functions & checks public (consistent with other WPA implementations)
Currently, most WPA implementations (e.g., `AndersenWaveDiff`) expose read-only functions (e.g., `printStat()`, `dumpTopLevelPtsTo()`, etc.) publically, as well as "constructors" like `solveAndWritePtsToFile()`, `readPtsFromFile()`, etc. However, `VersionedFlowSensitive` is the only one to mark these functions as `private`/`protected`. This makes it annoying to use polymorphism over the underlying PTA base class (i.e., `BVDataPTAImpl`) and the overridden virtual functions. This commit fixes that by marking these functions as public in the `VersionedFlowSensitive` WPA class. This change allows me to use polymorphism to conveniently try different WPA backends like this: ``` SVF::BVDataPTAImpl *pta = nullptr; switch(getChosenBackend()) { case Andersen_BASE: pta = new Andersen(...); break; case VFS_WPA: pta = new VersionedFlowSensitive(...); break; default: break; } ```
1 parent ce288cf commit 93446f6

File tree

1 file changed

+39
-38
lines changed

1 file changed

+39
-38
lines changed

svf/include/WPA/VersionedFlowSensitive.h

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,45 @@ class VersionedFlowSensitive : public FlowSensitive
110110
/// Override since we want to assign different weights based on versioning.
111111
virtual void cluster(void) override;
112112

113+
public:
114+
/// Returns true if l is a store node.
115+
virtual bool isStore(const NodeID l) const;
116+
117+
/// Returns true if l is a load node.
118+
virtual bool isLoad(const NodeID l) const;
119+
120+
/// Shared code for getConsume and getYield. They wrap this function.
121+
Version getVersion(const NodeID l, const NodeID o, const LocVersionMap &lvm) const;
122+
123+
/// Returns the consumed version of o at l. If no such version exists, returns invalidVersion.
124+
Version getConsume(const NodeID l, const NodeID o) const;
125+
126+
/// Returns the yielded version of o at l. If no such version exists, returns invalidVersion.
127+
Version getYield(const NodeID l, const NodeID o) const;
128+
129+
/// Returns the versions of o which rely on o:v.
130+
std::vector<Version> &getReliantVersions(const NodeID o, const Version v);
131+
132+
/// Returns the statements which rely on o:v.
133+
NodeBS &getStmtReliance(const NodeID o, const Version v);
134+
135+
/// Dumps versionReliance and stmtReliance.
136+
void dumpReliances(void) const;
137+
138+
/// Dumps maps consume and yield.
139+
void dumpLocVersionMaps(void) const;
140+
141+
void solveAndwritePtsToFile(const std::string& filename) override;
142+
143+
void writeVersionedAnalysisResultToFile(const std::string& filename);
144+
145+
void readVersionedAnalysisResultFromFile(std::ifstream& F);
146+
147+
void readPtsFromFile(const std::string& filename) override;
148+
149+
/// Dumps a MeldVersion to stdout.
150+
static void dumpMeldVersion(MeldVersion &v);
151+
113152
private:
114153
/// Prelabel the SVFG: set y(o) for stores and c(o) for delta nodes to a new version.
115154
void prelabel(void);
@@ -133,12 +172,6 @@ class VersionedFlowSensitive : public FlowSensitive
133172
/// Fills in isStoreMap and isLoadMap.
134173
virtual void buildIsStoreLoadMaps(void);
135174

136-
/// Returns true if l is a store node.
137-
virtual bool isStore(const NodeID l) const;
138-
139-
/// Returns true if l is a load node.
140-
virtual bool isLoad(const NodeID l) const;
141-
142175
/// Fills in deltaMap and deltaSourceMap for the SVFG.
143176
virtual void buildDeltaMaps(void);
144177

@@ -150,15 +183,6 @@ class VersionedFlowSensitive : public FlowSensitive
150183
/// edge to a delta node due to on-the-fly callgraph construction.
151184
virtual bool deltaSource(const NodeID l) const;
152185

153-
/// Shared code for getConsume and getYield. They wrap this function.
154-
Version getVersion(const NodeID l, const NodeID o, const LocVersionMap &lvm) const;
155-
156-
/// Returns the consumed version of o at l. If no such version exists, returns invalidVersion.
157-
Version getConsume(const NodeID l, const NodeID o) const;
158-
159-
/// Returns the yielded version of o at l. If no such version exists, returns invalidVersion.
160-
Version getYield(const NodeID l, const NodeID o) const;
161-
162186
/// Shared code for setConsume and setYield. They wrap this function.
163187
void setVersion(const NodeID l, const NodeID o, const Version v, LocVersionMap &lvm);
164188

@@ -168,29 +192,6 @@ class VersionedFlowSensitive : public FlowSensitive
168192
/// Sets the yielded version of o at l to v.
169193
void setYield(const NodeID l, const NodeID o, const Version v);
170194

171-
/// Returns the versions of o which rely on o:v.
172-
std::vector<Version> &getReliantVersions(const NodeID o, const Version v);
173-
174-
/// Returns the statements which rely on o:v.
175-
NodeBS &getStmtReliance(const NodeID o, const Version v);
176-
177-
/// Dumps versionReliance and stmtReliance.
178-
void dumpReliances(void) const;
179-
180-
/// Dumps maps consume and yield.
181-
void dumpLocVersionMaps(void) const;
182-
183-
void solveAndwritePtsToFile(const std::string& filename) override;
184-
185-
void writeVersionedAnalysisResultToFile(const std::string& filename);
186-
187-
void readVersionedAnalysisResultFromFile(std::ifstream& F);
188-
189-
void readPtsFromFile(const std::string& filename) override;
190-
191-
/// Dumps a MeldVersion to stdout.
192-
static void dumpMeldVersion(MeldVersion &v);
193-
194195
/// Maps locations to objects to a version. The object version is what is
195196
/// consumed at that location.
196197
LocVersionMap consume;

0 commit comments

Comments
 (0)