Skip to content

Commit 85d37f3

Browse files
committed
docstrings
1 parent a87023b commit 85d37f3

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

mlir/lib/Transforms/Utils/LoopInvariantCodeMotionUtils.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ static bool canBeHoisted(Operation *op,
6060
op, [&](OpOperand &operand) { return definedOutside(operand.get()); });
6161
}
6262

63+
/// Merges srcEffect's Memory Effect on its resource into the
64+
/// resourceConflicts map, flagging resources if the srcEffect
65+
/// results in a conflict
6366
static void mergeResource(
64-
DenseMap<TypeID, std::pair<bool, MemoryEffects::EffectInstance>> &dstMap,
67+
DenseMap<TypeID, std::pair<bool, MemoryEffects::EffectInstance>> &resourceConflicts,
6568
const MemoryEffects::EffectInstance &srcEffect,
6669
bool srcHasConflict) {
6770

@@ -72,11 +75,11 @@ static void mergeResource(
7275

7376
bool conflict = srcHasConflict || srcIsAllocOrFree;
7477

75-
auto dstIt = dstMap.find(srcResourceID);
78+
auto dstIt = resourceConflicts.find(srcResourceID);
7679

7780
// if it doesn't already exist, create entry for resource in map
78-
if (dstIt == dstMap.end()) {
79-
dstMap.insert(std::make_pair(srcResourceID, std::make_pair(conflict, srcEffect)));
81+
if (dstIt == resourceConflicts.end()) {
82+
resourceConflicts.insert(std::make_pair(srcResourceID, std::make_pair(conflict, srcEffect)));
8083
return;
8184
}
8285

@@ -96,6 +99,7 @@ static void mergeResource(
9699
dstIt->second =std::make_pair(conflict, srcEffect);
97100
}
98101

102+
/// Returns true if any of op's OpOperands are defined outside of loopLike
99103
static bool hasLoopVariantInput(LoopLikeOpInterface loopLike, Operation *op) {
100104
for (OpOperand &input : op->getOpOperands())
101105
if (!loopLike.isDefinedOutsideOfLoop(input.get()))
@@ -104,6 +108,11 @@ static bool hasLoopVariantInput(LoopLikeOpInterface loopLike, Operation *op) {
104108
return false;
105109
}
106110

111+
/// Returns true if:
112+
/// (a) any of the resources used by op's Memory Effects have been
113+
/// flagged as having a conflict within the resourceConflicts map
114+
/// (b) op doesn't have a MemoryEffectOpInterface or has one but
115+
/// without any specific effects
107116
static bool mayHaveMemoryEffectConflict(Operation *op,
108117
DenseMap<TypeID, std::pair<bool, MemoryEffects::EffectInstance>> &resourceConflicts) {
109118

0 commit comments

Comments
 (0)