Skip to content

Invalidate analyses after running Attributor in OpenMPOpt #74908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 20, 2023

Conversation

ivanradanov
Copy link
Contributor

Using the LoopInfo from OMPInfoCache after the Attributor ran resulted in a crash due to it being in an invalid state.

Using the LoopInfo from OMPInfoCache after the Attributor ran resulted
in a crash due to it being in an invalid state.
@llvmbot llvmbot added llvm:transforms clang:openmp OpenMP related changes to Clang labels Dec 9, 2023
@llvmbot
Copy link
Member

llvmbot commented Dec 9, 2023

@llvm/pr-subscribers-llvm-transforms

Author: Ivan R. Ivanov (ivanradanov)

Changes

Using the LoopInfo from OMPInfoCache after the Attributor ran resulted in a crash due to it being in an invalid state.


Full diff: https://github.com/llvm/llvm-project/pull/74908.diff

2 Files Affected:

  • (modified) llvm/include/llvm/Transforms/IPO/Attributor.h (+8)
  • (modified) llvm/lib/Transforms/IPO/OpenMPOpt.cpp (+3)
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 97b18e51beeeeb..d46b331f873adb 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -1157,6 +1157,10 @@ struct AnalysisGetter {
     return nullptr;
   }
 
+  void invalidate() {
+    FAM->clear();
+  }
+
   AnalysisGetter(FunctionAnalysisManager &FAM, bool CachedOnly = false)
       : FAM(&FAM), CachedOnly(CachedOnly) {}
   AnalysisGetter(Pass *P, bool CachedOnly = false)
@@ -1286,6 +1290,10 @@ struct InformationCache {
     return AssumeOnlyValues.contains(&I);
   }
 
+  void invalidate() {
+    AG.invalidate();
+  }
+
   /// Return the analysis result from a pass \p AP for function \p F.
   template <typename AP>
   typename AP::Result *getAnalysisResultForFunction(const Function &F,
diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index b2665161c090df..63092f51c13fad 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -2053,6 +2053,9 @@ struct OpenMPOpt {
     LLVM_DEBUG(dbgs() << "[Attributor] Done with " << SCC.size()
                       << " functions, result: " << Changed << ".\n");
 
+    if (Changed == ChangeStatus::CHANGED)
+      OMPInfoCache.invalidate();
+
     return Changed == ChangeStatus::CHANGED;
   }
 

Copy link

github-actions bot commented Dec 9, 2023

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Member

@jdoerfert jdoerfert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG two nits.

@ivanradanov
Copy link
Contributor Author

@jdoerfert Currently it only works when we use the new pass manager. Can we (or should we) support legacy passes too?

@jdoerfert
Copy link
Member

@jdoerfert Currently it only works when we use the new pass manager. Can we (or should we) support legacy passes too?

Does openmp-opt still expose the legacy PM version?
We should be able to delete that.

@jdoerfert jdoerfert merged commit 39f09ec into llvm:main Dec 20, 2023
@ivanradanov ivanradanov deleted the attributor-openmp-omp-patch branch December 21, 2023 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:openmp OpenMP related changes to Clang llvm:transforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants