AliasAnalysisEvaluator.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- AliasAnalysisEvaluator.h - Alias Analysis Accuracy Evaluator -------===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. /// \file
  14. ///
  15. /// This file implements a simple N^2 alias analysis accuracy evaluator. The
  16. /// analysis result is a set of statistics of how many times the AA
  17. /// infrastructure provides each kind of alias result and mod/ref result when
  18. /// queried with all pairs of pointers in the function.
  19. ///
  20. /// It can be used to evaluate a change in an alias analysis implementation,
  21. /// algorithm, or the AA pipeline infrastructure itself. It acts like a stable
  22. /// and easily tested consumer of all AA information exposed.
  23. ///
  24. /// This is inspired and adapted from code by: Naveen Neelakantam, Francesco
  25. /// Spadini, and Wojciech Stryjewski.
  26. ///
  27. //===----------------------------------------------------------------------===//
  28. #ifndef LLVM_ANALYSIS_ALIASANALYSISEVALUATOR_H
  29. #define LLVM_ANALYSIS_ALIASANALYSISEVALUATOR_H
  30. #include "llvm/IR/PassManager.h"
  31. namespace llvm {
  32. class AAResults;
  33. class Function;
  34. class FunctionPass;
  35. class AAEvaluator : public PassInfoMixin<AAEvaluator> {
  36. int64_t FunctionCount = 0;
  37. int64_t NoAliasCount = 0, MayAliasCount = 0, PartialAliasCount = 0;
  38. int64_t MustAliasCount = 0;
  39. int64_t NoModRefCount = 0, ModCount = 0, RefCount = 0, ModRefCount = 0;
  40. public:
  41. AAEvaluator() = default;
  42. AAEvaluator(AAEvaluator &&Arg)
  43. : FunctionCount(Arg.FunctionCount), NoAliasCount(Arg.NoAliasCount),
  44. MayAliasCount(Arg.MayAliasCount),
  45. PartialAliasCount(Arg.PartialAliasCount),
  46. MustAliasCount(Arg.MustAliasCount), NoModRefCount(Arg.NoModRefCount),
  47. ModCount(Arg.ModCount), RefCount(Arg.RefCount),
  48. ModRefCount(Arg.ModRefCount) {
  49. Arg.FunctionCount = 0;
  50. }
  51. ~AAEvaluator();
  52. /// Run the pass over the function.
  53. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
  54. private:
  55. // Allow the legacy pass to run this using an internal API.
  56. friend class AAEvalLegacyPass;
  57. void runInternal(Function &F, AAResults &AA);
  58. };
  59. /// Create a wrapper of the above for the legacy pass manager.
  60. FunctionPass *createAAEvalPass();
  61. }
  62. #endif
  63. #ifdef __GNUC__
  64. #pragma GCC diagnostic pop
  65. #endif