summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2017-01-15 08:20:50 +0000
committerChandler Carruth <chandlerc@gmail.com>2017-01-15 08:20:50 +0000
commit1ae34c35ba649dce4cd68c64fc3ff6e1fb89fd8d (patch)
treedc839504dccccbe10f149bcb29d5032dd20b4aa4 /llvm/lib
parent4504cd910c652e47af34c172f9c76636f32d2556 (diff)
downloadbcm5719-llvm-1ae34c35ba649dce4cd68c64fc3ff6e1fb89fd8d.tar.gz
bcm5719-llvm-1ae34c35ba649dce4cd68c64fc3ff6e1fb89fd8d.zip
[PM] Teach the optimization remarks emitter to handle invalidation
events. This pass sometimes has a pointer to BlockFrequencyInfo so it needs custom invalidation logic. It is also otherwise immutable so we can reduce the number of invalidations that happen substantially. llvm-svn: 292058
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp b/llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp
index fa8b07d61b0..da4e11d4303 100644
--- a/llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp
+++ b/llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp
@@ -45,6 +45,18 @@ OptimizationRemarkEmitter::OptimizationRemarkEmitter(Function *F)
BFI = OwnedBFI.get();
}
+bool OptimizationRemarkEmitter::invalidate(
+ Function &F, const PreservedAnalyses &PA,
+ FunctionAnalysisManager::Invalidator &Inv) {
+ // This analysis has no state and so can be trivially preserved but it needs
+ // a fresh view of BFI if it was constructed with one.
+ if (BFI && Inv.invalidate<BlockFrequencyAnalysis>(F, PA))
+ return true;
+
+ // Otherwise this analysis result remains valid.
+ return false;
+}
+
Optional<uint64_t> OptimizationRemarkEmitter::computeHotness(const Value *V) {
if (!BFI)
return None;
OpenPOWER on IntegriCloud