Skip to content

Commit

Permalink
Add a reset function for memlocation
Browse files Browse the repository at this point in the history
Swift SVN r32780
  • Loading branch information
trentxintong committed Oct 20, 2015
1 parent 6fe4314 commit fe3929a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions include/swift/SIL/MemLocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ class MemLocation {
/// construct the projection path to the field accessed.
void initialize(SILValue val);

/// Reset the memory location, i.e. clear base and path.
void reset() {
Base = SILValue();
Path.reset();
Kind = NormalKey;
}

/// Get the first level locations based on this location's first level
/// projection.
void getFirstLevelMemLocations(MemLocationList &Locs, SILModule *Mod);
Expand Down
3 changes: 2 additions & 1 deletion lib/SILPasses/UtilityPasses/MemLocationPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ class MemLocationPrinter : public SILFunctionTransform {
/// This tests the expand function in MemLocation class.
///
void printMemExpansion(SILFunction &Fn) {
MemLocation L;
MemLocationList Locs;
unsigned Counter = 0;
for (auto &BB : Fn) {
for (auto &II : BB) {
MemLocation L;
if (auto *LI = dyn_cast<LoadInst>(&II)) {
L.initialize(LI->getOperand());
if (!L.isValid())
Expand All @@ -84,6 +84,7 @@ class MemLocationPrinter : public SILFunctionTransform {
for (auto &Loc : Locs) {
llvm::outs() << Loc;
}
L.reset();
Locs.clear();
}
}
Expand Down

0 comments on commit fe3929a

Please sign in to comment.