@@ -317,17 +317,15 @@ LLVM_ABI TransformationMode hasDistributeTransformation(const Loop *L);
317317LLVM_ABI TransformationMode hasLICMVersioningTransformation (const Loop *L);
318318// / @}
319319
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 );
327325
328326// / Return either:
329327// / - 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.
331329// / - Else, a new estimate of the trip count from the latch branch weights of
332330// / \p L, if the estimation's implementation is able to handle the loop form
333331// / 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,
336334// / An estimated trip count is always a valid positive trip count, saturated at
337335// / \c UINT_MAX.
338336// /
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- // /
346337// / 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
348339// / 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
350341// / cannot compute that weight (e.g., if \p L does not have a latch block that
351342// / controls the loop exit) or the weight is zero (because zero cannot be
352343// / used to compute new branch weights that reflect the estimated trip count).
353344// /
354345// / TODO: Eventually, once all passes have migrated away from setting branch
355346// / weights to indicate estimated trip counts, this function will drop the
356347// / \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.
365348LLVM_ABI std::optional<unsigned >
366349getLoopEstimatedTripCount (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.
377354// /
378355// / In addition, if \p EstimatedLoopInvocationWeight, set the branch weight
379356// / 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
381358// / exit weight through the loop's latch.
382359// /
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.
388363// /
389364// / TODO: Eventually, once all passes have migrated away from setting branch
390365// / weights to indicate estimated trip counts, this function will drop the
391366// / \p EstimatedLoopInvocationWeight parameter.
392367LLVM_ABI bool setLoopEstimatedTripCount (
393- Loop *L, std::optional< unsigned > EstimatedTripCount,
368+ Loop *L, unsigned EstimatedTripCount,
394369 std::optional<unsigned > EstimatedLoopInvocationWeight = std::nullopt );
395370
396371// / Check inner loop (L) backedge count is known to be invariant on all
0 commit comments