Skip to content

Commit 39f09ec

Browse files
authored
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 <[email protected]>
1 parent 3c10e5b commit 39f09ec

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,12 @@ struct AnalysisGetter {
11571157
return nullptr;
11581158
}
11591159

1160+
/// Invalidates the analyses. Valid only when using the new pass manager.
1161+
void invalidateAnalyses() {
1162+
assert(FAM && "Can only be used from the new PM!");
1163+
FAM->clear();
1164+
}
1165+
11601166
AnalysisGetter(FunctionAnalysisManager &FAM, bool CachedOnly = false)
11611167
: FAM(&FAM), CachedOnly(CachedOnly) {}
11621168
AnalysisGetter(Pass *P, bool CachedOnly = false)
@@ -1286,6 +1292,10 @@ struct InformationCache {
12861292
return AssumeOnlyValues.contains(&I);
12871293
}
12881294

1295+
/// Invalidates the cached analyses. Valid only when using the new pass
1296+
/// manager.
1297+
void invalidateAnalyses() { AG.invalidateAnalyses(); }
1298+
12891299
/// Return the analysis result from a pass \p AP for function \p F.
12901300
template <typename AP>
12911301
typename AP::Result *getAnalysisResultForFunction(const Function &F,

llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,9 @@ struct OpenMPOpt {
20532053
LLVM_DEBUG(dbgs() << "[Attributor] Done with " << SCC.size()
20542054
<< " functions, result: " << Changed << ".\n");
20552055

2056+
if (Changed == ChangeStatus::CHANGED)
2057+
OMPInfoCache.invalidateAnalyses();
2058+
20562059
return Changed == ChangeStatus::CHANGED;
20572060
}
20582061

0 commit comments

Comments
 (0)