1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00

[LangRef] Adds llvm.loop.mustprogress loop metadata

This patch adds the llvm.loop.mustprogress loop metadata. This is to be
added to loops where the frontend language requires that the loop makes
observable interactions with the environment. This is the loop-level
equivalent to the function attribute `mustprogress` defined in D86233.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D88464
This commit is contained in:
Atmn Patel 2020-11-04 22:30:58 -05:00
parent c34a7c7b51
commit f818c9012a
3 changed files with 28 additions and 0 deletions

View File

@ -6326,6 +6326,15 @@ It is also possible to have nested parallel loops:
!3 = distinct !{} ; access group for instructions in the inner loop (which are implicitly contained in outer loop as well)
!4 = distinct !{} ; access group for instructions in the outer, but not the inner loop
'``llvm.loop.mustprogress``' Metadata
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ``llvm.loop.mustprogress`` metadata indicates that this loop is required to
terminate, unwind, or interact with the environment in an observable way e.g.
via a volatile memory access, I/O, or other synchronization. If such a loop is
not found to interact with the environment in an observable way, the loop may
be removed. This corresponds to the ``mustprogress`` function attribute.
'``irr_loop``' Metadata
^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -840,6 +840,9 @@ public:
/// unrolling pass is run more than once (which it generally is).
void setLoopAlreadyUnrolled();
/// Add llvm.loop.mustprogress to this loop's loop id metadata.
void setLoopMustProgress();
void dump() const;
void dumpVerbose() const;

View File

@ -539,6 +539,22 @@ void Loop::setLoopAlreadyUnrolled() {
setLoopID(NewLoopID);
}
void Loop::setLoopMustProgress() {
LLVMContext &Context = getHeader()->getContext();
MDNode *MustProgress = findOptionMDForLoop(this, "llvm.loop.mustprogress");
if (MustProgress)
return;
MDNode *MustProgressMD =
MDNode::get(Context, MDString::get(Context, "llvm.loop.mustprogress"));
MDNode *LoopID = getLoopID();
MDNode *NewLoopID =
makePostTransformationMetadata(Context, LoopID, {}, {MustProgressMD});
setLoopID(NewLoopID);
}
bool Loop::isAnnotatedParallel() const {
MDNode *DesiredLoopIdMetadata = getLoopID();