PassManager.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //===- PassManager.cpp - Infrastructure for managing & running IR passes --===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #include "llvm/ADT/STLExtras.h"
  10. #include "llvm/IR/LLVMContext.h"
  11. #include "llvm/IR/PassManager.h"
  12. using namespace llvm;
  13. char FunctionAnalysisManagerModuleProxy::PassID;
  14. FunctionAnalysisManagerModuleProxy::Result
  15. FunctionAnalysisManagerModuleProxy::run(Module &M) {
  16. assert(FAM->empty() && "Function analyses ran prior to the module proxy!");
  17. return Result(*FAM);
  18. }
  19. FunctionAnalysisManagerModuleProxy::Result::~Result() {
  20. // Clear out the analysis manager if we're being destroyed -- it means we
  21. // didn't even see an invalidate call when we got invalidated.
  22. FAM->clear();
  23. }
  24. bool FunctionAnalysisManagerModuleProxy::Result::invalidate(
  25. Module &M, const PreservedAnalyses &PA) {
  26. // If this proxy isn't marked as preserved, then we can't even invalidate
  27. // individual function analyses, there may be an invalid set of Function
  28. // objects in the cache making it impossible to incrementally preserve them.
  29. // Just clear the entire manager.
  30. if (!PA.preserved(ID()))
  31. FAM->clear();
  32. // Return false to indicate that this result is still a valid proxy.
  33. return false;
  34. }
  35. char ModuleAnalysisManagerFunctionProxy::PassID;