[polly] 5f58aae - [Polly][CodeGen] Allow nesting of BandAttr mark without loop.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 16 14:17:30 PDT 2021


Author: Michael Kruse
Date: 2021-03-16T16:17:07-05:00
New Revision: 5f58aae8f3dfbac9d7321546c66309381c54d194

URL: https://github.com/llvm/llvm-project/commit/5f58aae8f3dfbac9d7321546c66309381c54d194
DIFF: https://github.com/llvm/llvm-project/commit/5f58aae8f3dfbac9d7321546c66309381c54d194.diff

LOG: [Polly][CodeGen] Allow nesting of BandAttr mark without loop.

BandAttr markers are added as parents of schedule tree bands. These also
appear as markers its equivalent AST, but a band does not necessarily
corresponds to a loop in this. Iterations may be peeled or the loop
being unrolled (e.g. if it has just one iteration). In such cases it may
happend that there is not loop between a BandAttr marker and the marker
for a loop nested in the former parent band/loop.

Handle the situation by giving priority to the inner marker over the
outer.

Fixes the polly-x86_64-linux-test-suite buildbot.

Added: 
    

Modified: 
    polly/lib/CodeGen/IslNodeBuilder.cpp

Removed: 
    


################################################################################
diff  --git a/polly/lib/CodeGen/IslNodeBuilder.cpp b/polly/lib/CodeGen/IslNodeBuilder.cpp
index 1ce407d77829..fd0d50ac2233 100644
--- a/polly/lib/CodeGen/IslNodeBuilder.cpp
+++ b/polly/lib/CodeGen/IslNodeBuilder.cpp
@@ -428,9 +428,14 @@ void IslNodeBuilder::createMark(__isl_take isl_ast_node *Node) {
   }
 
   BandAttr *ChildLoopAttr = getLoopAttr(isl::manage_copy(Id));
+  BandAttr *AncestorLoopAttr;
   if (ChildLoopAttr) {
-    assert(!Annotator.getStagingAttrEnv() &&
-           "conflicting loop attr environments");
+    // Save current LoopAttr environment to restore again when leaving this
+    // subtree. This means there was no loop between the ancestor LoopAttr and
+    // this mark, i.e. the ancestor LoopAttr did not directly mark a loop. This
+    // can happen e.g. if the AST build peeled or unrolled the loop.
+    AncestorLoopAttr = Annotator.getStagingAttrEnv();
+
     Annotator.getStagingAttrEnv() = ChildLoopAttr;
   }
 
@@ -438,8 +443,8 @@ void IslNodeBuilder::createMark(__isl_take isl_ast_node *Node) {
 
   if (ChildLoopAttr) {
     assert(Annotator.getStagingAttrEnv() == ChildLoopAttr &&
-           "Nest  must not overwrite loop attr environment");
-    Annotator.getStagingAttrEnv() = nullptr;
+           "Nest must not overwrite loop attr environment");
+    Annotator.getStagingAttrEnv() = AncestorLoopAttr;
   }
 
   isl_id_free(Id);


        


More information about the llvm-commits mailing list