llvm-project/llvm/lib/Transforms/Scalar/LoopAccessAnalysisPrinter.cpp
Florian Hahn 7c0ff64b0f
[LAA] Change to function analysis for new PM.
At the moment, LoopAccessAnalysis is a loop analysis for the new pass
manager. The issue with that is that LAI caches SCEV expressions and
modifications in a loop may impact SCEV expressions in other loops, but
we do not have a convenient way to invalidate LAI for other loops
withing a loop pipeline.

To avoid this issue, turn it into a function analysis which returns a
manager object that keeps track of the individual LAI objects per loop.

Fixes #50940.

Fixes #51669.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D134606
2022-10-01 15:44:27 +01:00

34 lines
1.2 KiB
C++

//===- LoopAccessAnalysisPrinter.cpp - Loop Access Analysis Printer --------==//
//
// 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
//
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Scalar/LoopAccessAnalysisPrinter.h"
#include "llvm/ADT/PriorityWorklist.h"
#include "llvm/Analysis/LoopAccessAnalysis.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
using namespace llvm;
#define DEBUG_TYPE "loop-accesses"
PreservedAnalyses LoopAccessInfoPrinterPass::run(Function &F,
FunctionAnalysisManager &AM) {
auto &LAIs = AM.getResult<LoopAccessAnalysis>(F);
auto &LI = AM.getResult<LoopAnalysis>(F);
OS << "Loop access info in function '" << F.getName() << "':\n";
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);
}
return PreservedAnalyses::all();
}