[Attributor] Do not add AA to dependency graph after the update stage
authorShinji Okumura <okuraofvegetable@gmail.com>
Thu, 27 Aug 2020 20:16:18 +0000 (05:16 +0900)
committerShinji Okumura <okuraofvegetable@gmail.com>
Thu, 27 Aug 2020 20:16:18 +0000 (05:16 +0900)
If an AA is registered to the dependency graph in the manifest stage, Attributor aborts in `::manifestAttributes()`.
This patch prevents such termination.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D86734

llvm/include/llvm/Transforms/IPO/Attributor.h

index 7c5254d..802d2bd 100644 (file)
@@ -1104,8 +1104,10 @@ struct Attributor {
     assert(!AAPtr && "Attribute already in map!");
     AAPtr = &AA;
 
-    DG.SyntheticRoot.Deps.push_back(
-        AADepGraphNode::DepTy(&AA, unsigned(DepClassTy::REQUIRED)));
+    // Register AA with the synthetic root only before the manifest stage.
+    if (Phase == AttributorPhase::SEEDING || Phase == AttributorPhase::UPDATE)
+      DG.SyntheticRoot.Deps.push_back(
+          AADepGraphNode::DepTy(&AA, unsigned(DepClassTy::REQUIRED)));
 
     return AA;
   }