[llvm] 39f09ec - Invalidate analyses after running Attributor in OpenMPOpt (#74908)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 20 15:01:25 PST 2023
Author: Ivan R. Ivanov
Date: 2023-12-20T15:01:21-08:00
New Revision: 39f09ec245f3906bbc6b06500f7177a8001e7eed
URL: https://github.com/llvm/llvm-project/commit/39f09ec245f3906bbc6b06500f7177a8001e7eed
DIFF: https://github.com/llvm/llvm-project/commit/39f09ec245f3906bbc6b06500f7177a8001e7eed.diff
LOG: Invalidate analyses after running Attributor in OpenMPOpt (#74908)
Using the LoopInfo from OMPInfoCache after the Attributor ran resulted
in a crash due to it being in an invalid state.
---------
Co-authored-by: Ivan Radanov Ivanov <ivanov2 at llnl.gov>
Added:
Modified:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 50167708163ef0..30c51250af61ca 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -1157,6 +1157,12 @@ struct AnalysisGetter {
return nullptr;
}
+ /// Invalidates the analyses. Valid only when using the new pass manager.
+ void invalidateAnalyses() {
+ assert(FAM && "Can only be used from the new PM!");
+ FAM->clear();
+ }
+
AnalysisGetter(FunctionAnalysisManager &FAM, bool CachedOnly = false)
: FAM(&FAM), CachedOnly(CachedOnly) {}
AnalysisGetter(Pass *P, bool CachedOnly = false)
@@ -1286,6 +1292,10 @@ struct InformationCache {
return AssumeOnlyValues.contains(&I);
}
+ /// Invalidates the cached analyses. Valid only when using the new pass
+ /// manager.
+ void invalidateAnalyses() { AG.invalidateAnalyses(); }
+
/// 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 2c880316e0a1cd..4176d561363fbd 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.invalidateAnalyses();
+
return Changed == ChangeStatus::CHANGED;
}
More information about the llvm-commits
mailing list