@@ -52,8 +52,6 @@ typedef std::pair<const RuntimeCheckingPtrGroup *,
52
52
template <typename T, unsigned N> class SmallSetVector ;
53
53
template <typename T, unsigned N> class SmallPriorityWorklist ;
54
54
55
- const char *const LLVMLoopEstimatedTripCount = " llvm.loop.estimated_trip_count" ;
56
-
57
55
LLVM_ABI BasicBlock *InsertPreheaderForLoop (Loop *L, DominatorTree *DT,
58
56
LoopInfo *LI,
59
57
MemorySSAUpdater *MSSAU,
@@ -318,81 +316,28 @@ LLVM_ABI TransformationMode hasDistributeTransformation(const Loop *L);
318
316
LLVM_ABI TransformationMode hasLICMVersioningTransformation (const Loop *L);
319
317
// / @}
320
318
321
- // / Set the string \p MDString into the loop metadata of \p TheLoop while
322
- // / keeping other loop metadata intact. Set \p *V as its value, or set it
323
- // / without a value if \p V is \c std::nullopt to indicate the value is unknown.
324
- // / If \p MDString is already in the loop metadata, update it if its value (or
325
- // / lack of value) is different. Return true if metadata was changed.
326
- LLVM_ABI bool addStringMetadataToLoop (Loop *TheLoop, const char *MDString,
327
- std::optional<unsigned > V = 0 );
328
-
329
- // / Return either:
330
- // / - The value of \c llvm.loop.estimated_trip_count from the loop metadata of
331
- // / \p L, if that metadata is present and has a value.
332
- // / - Else, a new estimate of the trip count from the latch branch weights of
333
- // / \p L, if the estimation's implementation is able to handle the loop form
334
- // / of \p L (e.g., \p L must have a latch block that controls the loop exit).
335
- // / - Else, \c std::nullopt.
336
- // /
337
- // / An estimated trip count is always a valid positive trip count, saturated at
338
- // / \c UINT_MAX.
339
- // /
340
- // / Via \c LLVM_DEBUG, emit diagnostics that include "WARNING" when the metadata
341
- // / is in an unexpected state as that indicates some transformation has
342
- // / corrupted it. If \p DbgForInit, expect the metadata to be missing.
343
- // / Otherwise, expect the metadata to be present, and expect it to have no value
344
- // / only if the trip count is currently inestimable from the latch branch
345
- // / weights.
346
- // /
347
- // / In addition, if \p EstimatedLoopInvocationWeight, then either:
348
- // / - Set \p *EstimatedLoopInvocationWeight to the weight of the latch's branch
349
- // / to the loop exit.
350
- // / - Do not set it and return \c std::nullopt if the current implementation
351
- // / cannot compute that weight (e.g., if \p L does not have a latch block that
352
- // / controls the loop exit) or the weight is zero (because zero cannot be
353
- // / used to compute new branch weights that reflect the estimated trip count).
354
- // /
355
- // / TODO: Eventually, once all passes have migrated away from setting branch
356
- // / weights to indicate estimated trip counts, this function will drop the
357
- // / \p EstimatedLoopInvocationWeight parameter.
358
- // /
359
- // / TODO: There are also passes that currently do not consider estimated trip
360
- // / counts at all but that, for example, affect whether trip counts can be
361
- // / estimated from branch weights. Once all such passes have been adjusted to
362
- // / update this metadata, this function might stop estimating trip counts from
363
- // / branch weights and instead simply get the \c llvm.loop_estimated_trip_count
364
- // / metadata. See also the \c llvm.loop.estimated_trip_count entry in
365
- // / \c LangRef.rst.
319
+ // / Set input string into loop metadata by keeping other values intact.
320
+ // / If the string is already in loop metadata update value if it is
321
+ // / different.
322
+ LLVM_ABI void addStringMetadataToLoop (Loop *TheLoop, const char *MDString,
323
+ unsigned V = 0 );
324
+
325
+ // / Returns a loop's estimated trip count based on branch weight metadata.
326
+ // / In addition if \p EstimatedLoopInvocationWeight is not null it is
327
+ // / initialized with weight of loop's latch leading to the exit.
328
+ // / Returns a valid positive trip count, saturated at UINT_MAX, or std::nullopt
329
+ // / when a meaningful estimate cannot be made.
366
330
LLVM_ABI std::optional<unsigned >
367
331
getLoopEstimatedTripCount (Loop *L,
368
- unsigned *EstimatedLoopInvocationWeight = nullptr ,
369
- bool DbgForInit = false );
370
-
371
- // / Set \c llvm.loop.estimated_trip_count with the value \c *EstimatedTripCount
372
- // / in the loop metadata of \p L, or set it without a value if
373
- // / \c !EstimatedTripCount to indicate that \c getLoopEstimatedTripCount cannot
374
- // / estimate the trip count from latch branch weights. If
375
- // / \c !EstimatedTripCount but \c getLoopEstimatedTripCount can estimate the
376
- // / trip counts, future calls to \c getLoopEstimatedTripCount will diagnose the
377
- // / metadata as corrupt.
378
- // /
379
- // / In addition, if \p EstimatedLoopInvocationWeight, set the branch weight
380
- // / metadata of \p L to reflect that \p L has an estimated
381
- // / \c *EstimatedTripCount iterations and has \c *EstimatedLoopInvocationWeight
382
- // / exit weight through the loop's latch.
383
- // /
384
- // / Return false if \c llvm.loop.estimated_trip_count was already set according
385
- // / to \p EstimatedTripCount and so was not updated. Return false if
386
- // / \p EstimatedLoopInvocationWeight and if branch weight metadata could not be
387
- // / successfully updated (e.g., if \p L does not have a latch block that
388
- // / controls the loop exit). Otherwise, return true.
389
- // /
390
- // / TODO: Eventually, once all passes have migrated away from setting branch
391
- // / weights to indicate estimated trip counts, this function will drop the
392
- // / \p EstimatedLoopInvocationWeight parameter.
393
- LLVM_ABI bool setLoopEstimatedTripCount (
394
- Loop *L, std::optional<unsigned > EstimatedTripCount,
395
- std::optional<unsigned > EstimatedLoopInvocationWeight = std::nullopt );
332
+ unsigned *EstimatedLoopInvocationWeight = nullptr );
333
+
334
+ // / Set a loop's branch weight metadata to reflect that loop has \p
335
+ // / EstimatedTripCount iterations and \p EstimatedLoopInvocationWeight exits
336
+ // / through latch. Returns true if metadata is successfully updated, false
337
+ // / otherwise. Note that loop must have a latch block which controls loop exit
338
+ // / in order to succeed.
339
+ LLVM_ABI bool setLoopEstimatedTripCount (Loop *L, unsigned EstimatedTripCount,
340
+ unsigned EstimatedLoopInvocationWeight);
396
341
397
342
// / Check inner loop (L) backedge count is known to be invariant on all
398
343
// / iterations of its outer loop. If the loop has no parent, this is trivially
0 commit comments