2017-01-14 10:37:50 -05:00
|
|
|
//===- LoopAccessAnalysisPrinter.cpp - Loop Access Analysis Printer --------==//
|
|
|
|
|
//
|
2019-08-20 16:50:12 -04:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-01-14 10:37:50 -05:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#include "llvm/Transforms/Scalar/LoopAccessAnalysisPrinter.h"
|
2023-02-11 07:38:04 -05:00
|
|
|
#include "llvm/ADT/PriorityWorklist.h"
|
2017-01-14 10:37:50 -05:00
|
|
|
#include "llvm/Analysis/LoopAccessAnalysis.h"
|
2022-07-03 10:10:23 -04:00
|
|
|
#include "llvm/Analysis/LoopInfo.h"
|
2023-02-11 07:38:04 -05:00
|
|
|
#include "llvm/Transforms/Utils/LoopUtils.h"
|
|
|
|
|
|
2017-01-14 10:37:50 -05:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
|
|
#define DEBUG_TYPE "loop-accesses"
|
|
|
|
|
|
2023-02-11 07:38:04 -05:00
|
|
|
PreservedAnalyses LoopAccessInfoPrinterPass::run(Function &F,
|
|
|
|
|
FunctionAnalysisManager &AM) {
|
|
|
|
|
auto &LAIs = AM.getResult<LoopAccessAnalysis>(F);
|
|
|
|
|
auto &LI = AM.getResult<LoopAnalysis>(F);
|
2023-12-18 15:30:12 -05:00
|
|
|
OS << "Printing analysis 'Loop Access Analysis' for function '" << F.getName()
|
|
|
|
|
<< "':\n";
|
2023-02-11 07:38:04 -05:00
|
|
|
|
|
|
|
|
SmallPriorityWorklist<Loop *, 4> Worklist;
|
|
|
|
|
appendLoopsToWorklist(LI, Worklist);
|
|
|
|
|
while (!Worklist.empty()) {
|
|
|
|
|
Loop *L = Worklist.pop_back_val();
|
|
|
|
|
OS.indent(2) << L->getHeader()->getName() << ":\n";
|
|
|
|
|
LAIs.getInfo(*L).print(OS, 4);
|
|
|
|
|
}
|
2017-01-14 10:37:50 -05:00
|
|
|
return PreservedAnalyses::all();
|
|
|
|
|
}
|