@@ -60,8 +60,11 @@ static bool canBeHoisted(Operation *op,
60
60
op, [&](OpOperand &operand) { return definedOutside (operand.get ()); });
61
61
}
62
62
63
+ // / Merges srcEffect's Memory Effect on its resource into the
64
+ // / resourceConflicts map, flagging resources if the srcEffect
65
+ // / results in a conflict
63
66
static void mergeResource (
64
- DenseMap<TypeID, std::pair<bool , MemoryEffects::EffectInstance>> &dstMap ,
67
+ DenseMap<TypeID, std::pair<bool , MemoryEffects::EffectInstance>> &resourceConflicts ,
65
68
const MemoryEffects::EffectInstance &srcEffect,
66
69
bool srcHasConflict) {
67
70
@@ -72,11 +75,11 @@ static void mergeResource(
72
75
73
76
bool conflict = srcHasConflict || srcIsAllocOrFree;
74
77
75
- auto dstIt = dstMap .find (srcResourceID);
78
+ auto dstIt = resourceConflicts .find (srcResourceID);
76
79
77
80
// 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)));
80
83
return ;
81
84
}
82
85
@@ -96,6 +99,7 @@ static void mergeResource(
96
99
dstIt->second =std::make_pair (conflict, srcEffect);
97
100
}
98
101
102
+ // / Returns true if any of op's OpOperands are defined outside of loopLike
99
103
static bool hasLoopVariantInput (LoopLikeOpInterface loopLike, Operation *op) {
100
104
for (OpOperand &input : op->getOpOperands ())
101
105
if (!loopLike.isDefinedOutsideOfLoop (input.get ()))
@@ -104,6 +108,11 @@ static bool hasLoopVariantInput(LoopLikeOpInterface loopLike, Operation *op) {
104
108
return false ;
105
109
}
106
110
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
107
116
static bool mayHaveMemoryEffectConflict (Operation *op,
108
117
DenseMap<TypeID, std::pair<bool , MemoryEffects::EffectInstance>> &resourceConflicts) {
109
118
0 commit comments