LoopAccessAnalysisPrinter.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. //===- LoopAccessAnalysisPrinter.cpp - Loop Access Analysis Printer --------==//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #include "llvm/Transforms/Scalar/LoopAccessAnalysisPrinter.h"
  9. #include "llvm/ADT/PriorityWorklist.h"
  10. #include "llvm/Analysis/LoopAccessAnalysis.h"
  11. #include "llvm/Analysis/LoopInfo.h"
  12. #include "llvm/Transforms/Utils/LoopUtils.h"
  13. using namespace llvm;
  14. #define DEBUG_TYPE "loop-accesses"
  15. PreservedAnalyses LoopAccessInfoPrinterPass::run(Function &F,
  16. FunctionAnalysisManager &AM) {
  17. auto &LAIs = AM.getResult<LoopAccessAnalysis>(F);
  18. auto &LI = AM.getResult<LoopAnalysis>(F);
  19. OS << "Loop access info in function '" << F.getName() << "':\n";
  20. SmallPriorityWorklist<Loop *, 4> Worklist;
  21. appendLoopsToWorklist(LI, Worklist);
  22. while (!Worklist.empty()) {
  23. Loop *L = Worklist.pop_back_val();
  24. OS.indent(2) << L->getHeader()->getName() << ":\n";
  25. LAIs.getInfo(*L).print(OS, 4);
  26. }
  27. return PreservedAnalyses::all();
  28. }