Skip to content

Commit 89a8bd0

Browse files
committed
SIL: improve comments for the mayRead/mayWrite APIs in SILInstruction and AliasAnalysis
1 parent 123b356 commit 89a8bd0

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

include/swift/SIL/SILInstruction.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,14 +622,19 @@ class SILInstruction
622622

623623
/// Returns true if the instruction may write to memory, deinitialize memory,
624624
/// or have other unknown side effects.
625+
///
626+
/// For details see SILInstruction::MemoryBehavior.
625627
bool mayWriteToMemory() const {
626628
MemoryBehavior B = getMemoryBehavior();
627629
return B == MemoryBehavior::MayWrite ||
628630
B == MemoryBehavior::MayReadWrite ||
629631
B == MemoryBehavior::MayHaveSideEffects;
630632
}
631633

632-
/// Returns true if the instruction may read from memory.
634+
/// Returns true if the instruction may read from memory, or have other
635+
/// unknown side effects.
636+
///
637+
/// For details see SILInstruction::MemoryBehavior.
633638
bool mayReadFromMemory() const {
634639
MemoryBehavior B = getMemoryBehavior();
635640
return B == MemoryBehavior::MayRead ||
@@ -639,6 +644,8 @@ class SILInstruction
639644

640645
/// Returns true if the instruction may read from memory, write to memory,
641646
/// deinitialize memory, or have other unknown side effects.
647+
///
648+
/// For details see SILInstruction::MemoryBehavior.
642649
bool mayReadOrWriteMemory() const {
643650
return getMemoryBehavior() != MemoryBehavior::None;
644651
}

include/swift/SILOptimizer/Analysis/AliasAnalysis.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,26 +215,31 @@ class AliasAnalysis : public SILAnalysis {
215215
/// respect to V.
216216
MemoryBehavior computeMemoryBehaviorInner(SILInstruction *Inst, SILValue V);
217217

218-
/// Returns true if \p Inst may read from memory in a manner that
219-
/// affects V.
218+
/// Returns true if \p Inst may read from memory at address \p V.
219+
///
220+
/// For details see SILInstruction::MemoryBehavior::MayRead.
220221
bool mayReadFromMemory(SILInstruction *Inst, SILValue V) {
221222
auto B = computeMemoryBehavior(Inst, V);
222223
return B == MemoryBehavior::MayRead ||
223224
B == MemoryBehavior::MayReadWrite ||
224225
B == MemoryBehavior::MayHaveSideEffects;
225226
}
226227

227-
/// Returns true if \p Inst may write to memory, deinitialize memory, or have
228-
/// other side effects that may affect V.
228+
/// Returns true if \p Inst may write to memory or deinitialize memory at
229+
/// address \p V.
230+
///
231+
/// For details see SILInstruction::MemoryBehavior::MayWrite.
229232
bool mayWriteToMemory(SILInstruction *Inst, SILValue V) {
230233
auto B = computeMemoryBehavior(Inst, V);
231234
return B == MemoryBehavior::MayWrite ||
232235
B == MemoryBehavior::MayReadWrite ||
233236
B == MemoryBehavior::MayHaveSideEffects;
234237
}
235238

236-
/// Returns true if \p Inst may read to memory, write to memory, deinitialize
237-
/// memory, or have other side effects that may affect V.
239+
/// Returns true if \p Inst may read from memory, write to memory or
240+
/// deinitialize memory at address \p V.
241+
///
242+
/// For details see SILInstruction::MemoryBehavior.
238243
bool mayReadOrWriteMemory(SILInstruction *Inst, SILValue V) {
239244
auto B = computeMemoryBehavior(Inst, V);
240245
return MemoryBehavior::None != B;

0 commit comments

Comments
 (0)