Skip to content

Commit e3f9eac

Browse files
committed
[move-function] Implement the move-function checker for address only lets.
1 parent 8f22966 commit e3f9eac

File tree

8 files changed

+1298
-2
lines changed

8 files changed

+1298
-2
lines changed

include/swift/SIL/BasicBlockDatastructures.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ class BasicBlockSetVector {
4343
iterator begin() const { return vector.begin(); }
4444
iterator end() const { return vector.end(); }
4545

46+
llvm::iterator_range<iterator> getRange() const {
47+
return llvm::make_range(begin(), end());
48+
}
49+
4650
bool empty() const { return vector.empty(); }
4751

4852
bool contains(SILBasicBlock *block) const { return set.contains(block); }

include/swift/SIL/SILInstruction.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,10 @@ struct SILDebugVariable {
17931793
Implicit == V.Implicit && Type == V.Type && Loc == V.Loc &&
17941794
Scope == V.Scope;
17951795
}
1796+
1797+
bool isLet() const { return Name.size() && Constant; }
1798+
1799+
bool isVar() const { return Name.size() && !Constant; }
17961800
};
17971801

17981802
/// A DebugVariable where storage for the strings has been
@@ -2004,7 +2008,20 @@ class AllocStackInst final
20042008
auto VI = TailAllocatedDebugVariable(RawValue);
20052009
return VI.get(getDecl(), getTrailingObjects<char>(), AuxVarType, VarDeclLoc,
20062010
VarDeclScope, DIExprElements);
2007-
};
2011+
}
2012+
2013+
bool isLet() const {
2014+
if (auto varInfo = getVarInfo())
2015+
return varInfo->isLet();
2016+
return false;
2017+
}
2018+
2019+
bool isVar() const {
2020+
if (auto varInfo = getVarInfo())
2021+
return varInfo->isVar();
2022+
return false;
2023+
}
2024+
20082025
void setArgNo(unsigned N) {
20092026
auto RawValue = SILNode::Bits.AllocStackInst.VarInfo;
20102027
auto VI = TailAllocatedDebugVariable(RawValue);

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,9 @@ PASS(MoveKillsCopyableValuesChecker, "sil-move-kills-copyable-values-checker",
427427
"to _move do not have any uses later than the _move")
428428
PASS(LexicalLifetimeEliminator, "sil-lexical-lifetime-eliminator",
429429
"Pass that removes lexical lifetime markers from borrows and alloc stack")
430+
PASS(MoveKillsCopyableAddressesChecker, "sil-move-kills-copyable-addresses-checker",
431+
"Pass that checks that any copyable (non-move only) address that is passed "
432+
"to _move do not have any uses later than the _move")
430433
PASS(PruneVTables, "prune-vtables",
431434
"Mark class methods that do not require vtable dispatch")
432435
PASS_RANGE(AllPasses, AADumper, PruneVTables)

lib/SILOptimizer/Mandatory/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ target_sources(swiftSILOptimizer PRIVATE
2020
MandatoryInlining.cpp
2121
MoveOnlyChecker.cpp
2222
MoveKillsCopyableValuesChecker.cpp
23+
MoveKillsCopyableAddressesChecker.cpp
2324
NestedSemanticFunctionCheck.cpp
2425
OptimizeHopToExecutor.cpp
2526
PerformanceDiagnostics.cpp

0 commit comments

Comments
 (0)