@@ -128,13 +128,8 @@ void RuntimePointerChecking::insert(Loop *Lp, Value *Ptr, bool WritePtr,
128
128
assert (AR && " Invalid addrec expression" );
129
129
const SCEV *Ex = SE->getBackedgeTakenCount (Lp);
130
130
const SCEV *ScEnd = AR->evaluateAtIteration (Ex, *SE);
131
- Pointers.push_back (Ptr);
132
- Starts.push_back (AR->getStart ());
133
- Ends.push_back (ScEnd);
134
- IsWritePtr.push_back (WritePtr);
135
- DependencySetId.push_back (DepSetId);
136
- AliasSetId.push_back (ASId);
137
- Exprs.push_back (Sc);
131
+ Pointers.emplace_back (Ptr, AR->getStart (), ScEnd, WritePtr, DepSetId, ASId,
132
+ Sc);
138
133
}
139
134
140
135
bool RuntimePointerChecking::needsChecking (
@@ -162,24 +157,27 @@ static const SCEV *getMinFromExprs(const SCEV *I, const SCEV *J,
162
157
}
163
158
164
159
bool RuntimePointerChecking::CheckingPtrGroup::addPointer (unsigned Index) {
160
+ const SCEV *Start = RtCheck.Pointers [Index].Start ;
161
+ const SCEV *End = RtCheck.Pointers [Index].End ;
162
+
165
163
// Compare the starts and ends with the known minimum and maximum
166
164
// of this set. We need to know how we compare against the min/max
167
165
// of the set in order to be able to emit memchecks.
168
- const SCEV *Min0 = getMinFromExprs (RtCheck. Starts [Index] , Low, RtCheck.SE );
166
+ const SCEV *Min0 = getMinFromExprs (Start , Low, RtCheck.SE );
169
167
if (!Min0)
170
168
return false ;
171
169
172
- const SCEV *Min1 = getMinFromExprs (RtCheck. Ends [Index] , High, RtCheck.SE );
170
+ const SCEV *Min1 = getMinFromExprs (End , High, RtCheck.SE );
173
171
if (!Min1)
174
172
return false ;
175
173
176
174
// Update the low bound expression if we've found a new min value.
177
- if (Min0 == RtCheck. Starts [Index] )
178
- Low = RtCheck. Starts [Index] ;
175
+ if (Min0 == Start )
176
+ Low = Start ;
179
177
180
178
// Update the high bound expression if we've found a new max value.
181
- if (Min1 != RtCheck. Ends [Index] )
182
- High = RtCheck. Ends [Index] ;
179
+ if (Min1 != End )
180
+ High = End ;
183
181
184
182
Members.push_back (Index);
185
183
return true ;
@@ -217,8 +215,8 @@ void RuntimePointerChecking::groupChecks(
217
215
unsigned TotalComparisons = 0 ;
218
216
219
217
DenseMap<Value *, unsigned > PositionMap;
220
- for (unsigned Pointer = 0 ; Pointer < Pointers.size (); ++Pointer )
221
- PositionMap[Pointers[Pointer] ] = Pointer ;
218
+ for (unsigned Index = 0 ; Index < Pointers.size (); ++Index )
219
+ PositionMap[Pointers[Index]. PointerValue ] = Index ;
222
220
223
221
// We need to keep track of what pointers we've already seen so we
224
222
// don't process them twice.
@@ -233,7 +231,8 @@ void RuntimePointerChecking::groupChecks(
233
231
if (Seen.count (I))
234
232
continue ;
235
233
236
- MemoryDepChecker::MemAccessInfo Access (Pointers[I], IsWritePtr[I]);
234
+ MemoryDepChecker::MemAccessInfo Access (Pointers[I].PointerValue ,
235
+ Pointers[I].IsWritePtr );
237
236
238
237
SmallVector<CheckingPtrGroup, 2 > Groups;
239
238
auto LeaderI = DepCands.findValue (DepCands.getLeaderValue (Access));
@@ -283,16 +282,19 @@ void RuntimePointerChecking::groupChecks(
283
282
284
283
bool RuntimePointerChecking::needsChecking (
285
284
unsigned I, unsigned J, const SmallVectorImpl<int > *PtrPartition) const {
285
+ const PointerInfo &PointerI = Pointers[I];
286
+ const PointerInfo &PointerJ = Pointers[J];
287
+
286
288
// No need to check if two readonly pointers intersect.
287
- if (!IsWritePtr[I] && !IsWritePtr[J] )
289
+ if (!PointerI. IsWritePtr && !PointerJ. IsWritePtr )
288
290
return false ;
289
291
290
292
// Only need to check pointers between two different dependency sets.
291
- if (DependencySetId[I] == DependencySetId[J] )
293
+ if (PointerI. DependencySetId == PointerJ. DependencySetId )
292
294
return false ;
293
295
294
296
// Only need to check pointers in the same alias set.
295
- if (AliasSetId[I] != AliasSetId[J] )
297
+ if (PointerI. AliasSetId != PointerJ. AliasSetId )
296
298
return false ;
297
299
298
300
// If PtrPartition is set omit checks between pointers of the same partition.
@@ -319,8 +321,8 @@ void RuntimePointerChecking::print(
319
321
OS.indent (Depth + 2 ) << " Comparing group " << I << " :\n " ;
320
322
321
323
for (unsigned K = 0 ; K < CheckingGroups[I].Members .size (); ++K) {
322
- OS.indent (Depth + 2 ) << *Pointers[CheckingGroups[I]. Members [K]]
323
- << " \n " ;
324
+ OS.indent (Depth + 2 )
325
+ << *Pointers[CheckingGroups[I]. Members [K]]. PointerValue << " \n " ;
324
326
if (PtrPartition)
325
327
OS << " (Partition: "
326
328
<< (*PtrPartition)[CheckingGroups[I].Members [K]] << " )"
@@ -330,8 +332,8 @@ void RuntimePointerChecking::print(
330
332
OS.indent (Depth + 2 ) << " Against group " << J << " :\n " ;
331
333
332
334
for (unsigned K = 0 ; K < CheckingGroups[J].Members .size (); ++K) {
333
- OS.indent (Depth + 2 ) << *Pointers[CheckingGroups[J]. Members [K]]
334
- << " \n " ;
335
+ OS.indent (Depth + 2 )
336
+ << *Pointers[CheckingGroups[J]. Members [K]]. PointerValue << " \n " ;
335
337
if (PtrPartition)
336
338
OS << " (Partition: "
337
339
<< (*PtrPartition)[CheckingGroups[J].Members [K]] << " )"
@@ -345,7 +347,8 @@ void RuntimePointerChecking::print(
345
347
OS.indent (Depth + 4 ) << " (Low: " << *CheckingGroups[I].Low
346
348
<< " High: " << *CheckingGroups[I].High << " )\n " ;
347
349
for (unsigned J = 0 ; J < CheckingGroups[I].Members .size (); ++J) {
348
- OS.indent (Depth + 6 ) << " Member: " << *Exprs[CheckingGroups[I].Members [J]]
350
+ OS.indent (Depth + 6 ) << " Member: "
351
+ << *Pointers[CheckingGroups[I].Members [J]].Expr
349
352
<< " \n " ;
350
353
}
351
354
}
@@ -575,14 +578,15 @@ bool AccessAnalysis::canCheckPtrAtRT(RuntimePointerChecking &RtCheck,
575
578
for (unsigned i = 0 ; i < NumPointers; ++i) {
576
579
for (unsigned j = i + 1 ; j < NumPointers; ++j) {
577
580
// Only need to check pointers between two different dependency sets.
578
- if (RtCheck.DependencySetId [i] == RtCheck.DependencySetId [j])
581
+ if (RtCheck.Pointers [i].DependencySetId ==
582
+ RtCheck.Pointers [j].DependencySetId )
579
583
continue ;
580
584
// Only need to check pointers in the same alias set.
581
- if (RtCheck.AliasSetId [i] != RtCheck.AliasSetId [j])
585
+ if (RtCheck.Pointers [i]. AliasSetId != RtCheck.Pointers [j]. AliasSetId )
582
586
continue ;
583
587
584
- Value *PtrI = RtCheck.Pointers [i];
585
- Value *PtrJ = RtCheck.Pointers [j];
588
+ Value *PtrI = RtCheck.Pointers [i]. PointerValue ;
589
+ Value *PtrJ = RtCheck.Pointers [j]. PointerValue ;
586
590
587
591
unsigned ASi = PtrI->getType ()->getPointerAddressSpace ();
588
592
unsigned ASj = PtrJ->getType ()->getPointerAddressSpace ();
@@ -1577,7 +1581,7 @@ std::pair<Instruction *, Instruction *> LoopAccessInfo::addRuntimeCheck(
1577
1581
for (unsigned i = 0 ; i < PtrRtChecking.CheckingGroups .size (); ++i) {
1578
1582
const RuntimePointerChecking::CheckingPtrGroup &CG =
1579
1583
PtrRtChecking.CheckingGroups [i];
1580
- Value *Ptr = PtrRtChecking.Pointers [CG.Members [0 ]];
1584
+ Value *Ptr = PtrRtChecking.Pointers [CG.Members [0 ]]. PointerValue ;
1581
1585
const SCEV *Sc = SE->getSCEV (Ptr);
1582
1586
1583
1587
if (SE->isLoopInvariant (Sc, TheLoop)) {
0 commit comments