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