Skip to content

Commit 62adc83

Browse files
authored
[NFC][LLVM] Namespace cleanup in LoopFuse (llvm#163758)
Additionally, make the `Loop` argument to `printLoop` const.
1 parent fdbd75d commit 62adc83

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

llvm/include/llvm/Analysis/LoopInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ class LLVM_ABI LoopInfoWrapperPass : public FunctionPass {
617617
};
618618

619619
/// Function to print a loop's contents as LLVM's text IR assembly.
620-
LLVM_ABI void printLoop(Loop &L, raw_ostream &OS,
620+
LLVM_ABI void printLoop(const Loop &L, raw_ostream &OS,
621621
const std::string &Banner = "");
622622

623623
/// Find and return the loop attribute node for the attribute @p Name in

llvm/lib/Analysis/LoopInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,8 +986,8 @@ PreservedAnalyses LoopPrinterPass::run(Function &F,
986986
return PreservedAnalyses::all();
987987
}
988988

989-
void llvm::printLoop(Loop &L, raw_ostream &OS, const std::string &Banner) {
990-
989+
void llvm::printLoop(const Loop &L, raw_ostream &OS,
990+
const std::string &Banner) {
991991
if (forcePrintModuleIR()) {
992992
// handling -print-module-scope
993993
OS << Banner << " (loop: ";

llvm/lib/Transforms/Scalar/LoopFuse.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ struct FusionCandidate {
368368
Valid = false;
369369
}
370370

371-
bool reportInvalidCandidate(llvm::Statistic &Stat) const {
371+
bool reportInvalidCandidate(Statistic &Stat) const {
372372
using namespace ore;
373373
assert(L && Preheader && "Fusion candidate not initialized properly!");
374374
#if LLVM_ENABLE_STATS
@@ -445,6 +445,7 @@ struct FusionCandidateCompare {
445445
"No dominance relationship between these fusion candidates!");
446446
}
447447
};
448+
} // namespace
448449

449450
using LoopVector = SmallVector<Loop *, 4>;
450451

@@ -461,9 +462,15 @@ using LoopVector = SmallVector<Loop *, 4>;
461462
using FusionCandidateSet = std::set<FusionCandidate, FusionCandidateCompare>;
462463
using FusionCandidateCollection = SmallVector<FusionCandidateSet, 4>;
463464

464-
#if !defined(NDEBUG)
465-
static llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
466-
const FusionCandidate &FC) {
465+
#ifndef NDEBUG
466+
static void printLoopVector(const LoopVector &LV) {
467+
dbgs() << "****************************\n";
468+
for (const Loop *L : LV)
469+
printLoop(*L, dbgs());
470+
dbgs() << "****************************\n";
471+
}
472+
473+
static raw_ostream &operator<<(raw_ostream &OS, const FusionCandidate &FC) {
467474
if (FC.isValid())
468475
OS << FC.Preheader->getName();
469476
else
@@ -472,8 +479,8 @@ static llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
472479
return OS;
473480
}
474481

475-
static llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
476-
const FusionCandidateSet &CandSet) {
482+
static raw_ostream &operator<<(raw_ostream &OS,
483+
const FusionCandidateSet &CandSet) {
477484
for (const FusionCandidate &FC : CandSet)
478485
OS << FC << '\n';
479486

@@ -489,7 +496,9 @@ printFusionCandidates(const FusionCandidateCollection &FusionCandidates) {
489496
dbgs() << "****************************\n";
490497
}
491498
}
492-
#endif
499+
#endif // NDEBUG
500+
501+
namespace {
493502

494503
/// Collect all loops in function at the same nest level, starting at the
495504
/// outermost level.
@@ -550,15 +559,6 @@ struct LoopDepthTree {
550559
LoopsOnLevelTy LoopsOnLevel;
551560
};
552561

553-
#ifndef NDEBUG
554-
static void printLoopVector(const LoopVector &LV) {
555-
dbgs() << "****************************\n";
556-
for (auto *L : LV)
557-
printLoop(*L, dbgs());
558-
dbgs() << "****************************\n";
559-
}
560-
#endif
561-
562562
struct LoopFuser {
563563
private:
564564
// Sets of control flow equivalent fusion candidates for a given nest level.
@@ -1850,7 +1850,7 @@ struct LoopFuser {
18501850
/// <Cand1 Preheader> and <Cand2 Preheader>: <Stat Description>
18511851
template <typename RemarkKind>
18521852
void reportLoopFusion(const FusionCandidate &FC0, const FusionCandidate &FC1,
1853-
llvm::Statistic &Stat) {
1853+
Statistic &Stat) {
18541854
assert(FC0.Preheader && FC1.Preheader &&
18551855
"Expecting valid fusion candidates");
18561856
using namespace ore;

0 commit comments

Comments
 (0)