Skip to content

Commit c288b7b

Browse files
committed
Rename to Legacy, add printer and invalidate
1 parent ef90ea7 commit c288b7b

12 files changed

+66
-32
lines changed

llvm/include/llvm/CodeGen/LiveDebugVariables.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,26 @@ class LiveDebugVariables {
5353
/// @param VRM Rename virtual registers according to map.
5454
void emitDebugValues(VirtRegMap *VRM);
5555

56+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
5657
/// dump - Print data structures to dbgs().
5758
void dump() const;
59+
#endif
60+
61+
void print(raw_ostream &OS) const;
5862

5963
void releaseMemory();
64+
65+
bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA,
66+
MachineFunctionAnalysisManager::Invalidator &Inv);
6067
};
6168

62-
class LiveDebugVariablesWrapperPass : public MachineFunctionPass {
69+
class LiveDebugVariablesWrapperLegacy : public MachineFunctionPass {
6370
std::unique_ptr<LiveDebugVariables> Impl;
6471

6572
public:
6673
static char ID; // Pass identification, replacement for typeid
6774

68-
LiveDebugVariablesWrapperPass();
75+
LiveDebugVariablesWrapperLegacy();
6976

7077
bool runOnMachineFunction(MachineFunction &) override;
7178

@@ -91,6 +98,12 @@ class LiveDebugVariablesAnalysis
9198
Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM);
9299
};
93100

101+
class LiveDebugVariablesPrinterPass
102+
: public PassInfoMixin<LiveDebugVariablesPrinterPass> {
103+
public:
104+
PreservedAnalyses run(MachineFunction &MF,
105+
MachineFunctionAnalysisManager &MFAM);
106+
};
94107
} // end namespace llvm
95108

96109
#endif // LLVM_CODEGEN_LIVEDEBUGVARIABLES_H

llvm/include/llvm/InitializePasses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ void initializeLegalizerPass(PassRegistry &);
154154
void initializeGISelCSEAnalysisWrapperPassPass(PassRegistry &);
155155
void initializeGISelKnownBitsAnalysisPass(PassRegistry &);
156156
void initializeLiveDebugValuesPass(PassRegistry &);
157-
void initializeLiveDebugVariablesWrapperPassPass(PassRegistry &);
157+
void initializeLiveDebugVariablesWrapperLegacyPass(PassRegistry &);
158158
void initializeLiveIntervalsWrapperPassPass(PassRegistry &);
159159
void initializeLiveRangeShrinkPass(PassRegistry &);
160160
void initializeLiveRegMatrixWrapperLegacyPass(PassRegistry &);

llvm/lib/CodeGen/CodeGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
5959
initializeInterleavedAccessPass(Registry);
6060
initializeJMCInstrumenterPass(Registry);
6161
initializeLiveDebugValuesPass(Registry);
62-
initializeLiveDebugVariablesWrapperPassPass(Registry);
62+
initializeLiveDebugVariablesWrapperLegacyPass(Registry);
6363
initializeLiveIntervalsWrapperPassPass(Registry);
6464
initializeLiveRangeShrinkPass(Registry);
6565
initializeLiveStacksPass(Registry);

llvm/lib/CodeGen/LiveDebugVariables.cpp

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,27 @@ EnableLDV("live-debug-variables", cl::init(true),
7474
STATISTIC(NumInsertedDebugValues, "Number of DBG_VALUEs inserted");
7575
STATISTIC(NumInsertedDebugLabels, "Number of DBG_LABELs inserted");
7676

77-
char LiveDebugVariablesWrapperPass::ID = 0;
77+
char LiveDebugVariablesWrapperLegacy::ID = 0;
7878

79-
INITIALIZE_PASS_BEGIN(LiveDebugVariablesWrapperPass, DEBUG_TYPE,
79+
INITIALIZE_PASS_BEGIN(LiveDebugVariablesWrapperLegacy, DEBUG_TYPE,
8080
"Debug Variable Analysis", false, false)
8181
INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass)
8282
INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass)
83-
INITIALIZE_PASS_END(LiveDebugVariablesWrapperPass, DEBUG_TYPE,
83+
INITIALIZE_PASS_END(LiveDebugVariablesWrapperLegacy, DEBUG_TYPE,
8484
"Debug Variable Analysis", false, false)
8585

86-
void LiveDebugVariablesWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
86+
void LiveDebugVariablesWrapperLegacy::getAnalysisUsage(
87+
AnalysisUsage &AU) const {
8788
AU.addRequired<MachineDominatorTreeWrapperPass>();
8889
AU.addRequiredTransitive<LiveIntervalsWrapperPass>();
8990
AU.setPreservesAll();
9091
MachineFunctionPass::getAnalysisUsage(AU);
9192
}
9293

93-
LiveDebugVariablesWrapperPass::LiveDebugVariablesWrapperPass()
94+
LiveDebugVariablesWrapperLegacy::LiveDebugVariablesWrapperLegacy()
9495
: MachineFunctionPass(ID) {
95-
initializeLiveDebugVariablesWrapperPassPass(*PassRegistry::getPassRegistry());
96+
initializeLiveDebugVariablesWrapperLegacyPass(
97+
*PassRegistry::getPassRegistry());
9698
}
9799

98100
enum : unsigned { UndefLocNo = ~0U };
@@ -673,7 +675,6 @@ class LDVImpl {
673675

674676
} // end anonymous namespace
675677

676-
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
677678
static void printDebugLoc(const DebugLoc &DL, raw_ostream &CommentOS,
678679
const LLVMContext &Ctx) {
679680
if (!DL)
@@ -761,7 +762,6 @@ void LDVImpl::print(raw_ostream &OS) {
761762
for (auto &userLabel : userLabels)
762763
userLabel->print(OS, TRI);
763764
}
764-
#endif
765765

766766
void UserValue::mapVirtRegs(LDVImpl *LDV) {
767767
for (const MachineOperand &MO : locations)
@@ -1297,7 +1297,8 @@ static void removeDebugInstrs(MachineFunction &mf) {
12971297
}
12981298
}
12991299

1300-
bool LiveDebugVariablesWrapperPass::runOnMachineFunction(MachineFunction &mf) {
1300+
bool LiveDebugVariablesWrapperLegacy::runOnMachineFunction(
1301+
MachineFunction &mf) {
13011302
auto *LIS = &getAnalysis<LiveIntervalsWrapperPass>().getLIS();
13021303

13031304
Impl = std::make_unique<LiveDebugVariables>();
@@ -1316,6 +1317,14 @@ LiveDebugVariablesAnalysis::run(MachineFunction &MF,
13161317
return LDV;
13171318
}
13181319

1320+
PreservedAnalyses
1321+
LiveDebugVariablesPrinterPass::run(MachineFunction &MF,
1322+
MachineFunctionAnalysisManager &MFAM) {
1323+
auto &LDV = MFAM.getResult<LiveDebugVariablesAnalysis>(MF);
1324+
LDV.print(dbgs());
1325+
return PreservedAnalyses::all();
1326+
}
1327+
13191328
void LiveDebugVariables::Deleter::operator()(void *Ptr) const {
13201329
delete static_cast<LDVImpl *>(Ptr);
13211330
}
@@ -1325,6 +1334,16 @@ void LiveDebugVariables::releaseMemory() {
13251334
static_cast<LDVImpl *>(PImpl.get())->clear();
13261335
}
13271336

1337+
bool LiveDebugVariables::invalidate(
1338+
MachineFunction &, const PreservedAnalyses &PA,
1339+
MachineFunctionAnalysisManager::Invalidator &) {
1340+
auto PAC = PA.getChecker<LiveDebugVariablesAnalysis>();
1341+
// Some architectures split the register allocation into multiple phases based
1342+
// on register classes. This requires preserving analyses between the phases
1343+
// by default.
1344+
return PAC.preservedWhenStateless();
1345+
}
1346+
13281347
void LiveDebugVariables::analyze(MachineFunction &MF, LiveIntervals *LIS) {
13291348
if (!EnableLDV)
13301349
return;
@@ -1977,8 +1996,10 @@ void LiveDebugVariables::emitDebugValues(VirtRegMap *VRM) {
19771996
}
19781997

19791998
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1980-
LLVM_DUMP_METHOD void LiveDebugVariables::dump() const {
1999+
LLVM_DUMP_METHOD void LiveDebugVariables::dump() const { print(dbgs()); }
2000+
#endif
2001+
2002+
void LiveDebugVariables::print(raw_ostream &OS) const {
19812003
if (PImpl)
1982-
static_cast<LDVImpl *>(PImpl.get())->print(dbgs());
2004+
static_cast<LDVImpl *>(PImpl.get())->print(OS);
19832005
}
1984-
#endif

llvm/lib/CodeGen/RegAllocBasic.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ char &llvm::RABasicID = RABasic::ID;
130130

131131
INITIALIZE_PASS_BEGIN(RABasic, "regallocbasic", "Basic Register Allocator",
132132
false, false)
133-
INITIALIZE_PASS_DEPENDENCY(LiveDebugVariablesWrapperPass)
133+
INITIALIZE_PASS_DEPENDENCY(LiveDebugVariablesWrapperLegacy)
134134
INITIALIZE_PASS_DEPENDENCY(SlotIndexesWrapperPass)
135135
INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass)
136136
INITIALIZE_PASS_DEPENDENCY(RegisterCoalescer)
@@ -180,8 +180,8 @@ void RABasic::getAnalysisUsage(AnalysisUsage &AU) const {
180180
AU.addRequired<LiveIntervalsWrapperPass>();
181181
AU.addPreserved<LiveIntervalsWrapperPass>();
182182
AU.addPreserved<SlotIndexesWrapperPass>();
183-
AU.addRequired<LiveDebugVariablesWrapperPass>();
184-
AU.addPreserved<LiveDebugVariablesWrapperPass>();
183+
AU.addRequired<LiveDebugVariablesWrapperLegacy>();
184+
AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
185185
AU.addRequired<LiveStacks>();
186186
AU.addPreserved<LiveStacks>();
187187
AU.addRequired<ProfileSummaryInfoWrapperPass>();

llvm/lib/CodeGen/RegAllocGreedy.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ char &llvm::RAGreedyID = RAGreedy::ID;
151151

152152
INITIALIZE_PASS_BEGIN(RAGreedy, "greedy",
153153
"Greedy Register Allocator", false, false)
154-
INITIALIZE_PASS_DEPENDENCY(LiveDebugVariablesWrapperPass)
154+
INITIALIZE_PASS_DEPENDENCY(LiveDebugVariablesWrapperLegacy)
155155
INITIALIZE_PASS_DEPENDENCY(SlotIndexesWrapperPass)
156156
INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass)
157157
INITIALIZE_PASS_DEPENDENCY(RegisterCoalescer)
@@ -204,8 +204,8 @@ void RAGreedy::getAnalysisUsage(AnalysisUsage &AU) const {
204204
AU.addPreserved<LiveIntervalsWrapperPass>();
205205
AU.addRequired<SlotIndexesWrapperPass>();
206206
AU.addPreserved<SlotIndexesWrapperPass>();
207-
AU.addRequired<LiveDebugVariablesWrapperPass>();
208-
AU.addPreserved<LiveDebugVariablesWrapperPass>();
207+
AU.addRequired<LiveDebugVariablesWrapperLegacy>();
208+
AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
209209
AU.addRequired<LiveStacks>();
210210
AU.addPreserved<LiveStacks>();
211211
AU.addRequired<MachineDominatorTreeWrapperPass>();
@@ -2732,7 +2732,7 @@ bool RAGreedy::runOnMachineFunction(MachineFunction &mf) {
27322732
Loops = &getAnalysis<MachineLoopInfoWrapperPass>().getLI();
27332733
Bundles = &getAnalysis<EdgeBundlesWrapperLegacy>().getEdgeBundles();
27342734
SpillPlacer = &getAnalysis<SpillPlacementWrapperLegacy>().getResult();
2735-
DebugVars = &getAnalysis<LiveDebugVariablesWrapperPass>().getLDV();
2735+
DebugVars = &getAnalysis<LiveDebugVariablesWrapperLegacy>().getLDV();
27362736

27372737
initializeCSRCost();
27382738

llvm/lib/CodeGen/RegAllocGreedy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace llvm {
4343
class AllocationOrder;
4444
class AnalysisUsage;
4545
class EdgeBundles;
46-
class LiveDebugVariablesWrapperPass;
46+
class LiveDebugVariablesWrapperLegacy;
4747
class LiveIntervals;
4848
class LiveRegMatrix;
4949
class MachineBasicBlock;

llvm/lib/CodeGen/StackSlotColoring.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ namespace {
159159
// may be invoked multiple times requiring it to save these analyses to be
160160
// used by RA later.
161161
AU.addPreserved<LiveIntervalsWrapperPass>();
162-
AU.addPreserved<LiveDebugVariablesWrapperPass>();
162+
AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
163163

164164
MachineFunctionPass::getAnalysisUsage(AU);
165165
}

llvm/lib/CodeGen/VirtRegMap.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ INITIALIZE_PASS_BEGIN(VirtRegRewriter, "virtregrewriter",
251251
"Virtual Register Rewriter", false, false)
252252
INITIALIZE_PASS_DEPENDENCY(SlotIndexesWrapperPass)
253253
INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass)
254-
INITIALIZE_PASS_DEPENDENCY(LiveDebugVariablesWrapperPass)
254+
INITIALIZE_PASS_DEPENDENCY(LiveDebugVariablesWrapperLegacy)
255255
INITIALIZE_PASS_DEPENDENCY(LiveRegMatrixWrapperLegacy)
256256
INITIALIZE_PASS_DEPENDENCY(LiveStacks)
257257
INITIALIZE_PASS_DEPENDENCY(VirtRegMapWrapperLegacy)
@@ -264,14 +264,14 @@ void VirtRegRewriter::getAnalysisUsage(AnalysisUsage &AU) const {
264264
AU.addPreserved<LiveIntervalsWrapperPass>();
265265
AU.addRequired<SlotIndexesWrapperPass>();
266266
AU.addPreserved<SlotIndexesWrapperPass>();
267-
AU.addRequired<LiveDebugVariablesWrapperPass>();
267+
AU.addRequired<LiveDebugVariablesWrapperLegacy>();
268268
AU.addRequired<LiveStacks>();
269269
AU.addPreserved<LiveStacks>();
270270
AU.addRequired<VirtRegMapWrapperLegacy>();
271271
AU.addRequired<LiveRegMatrixWrapperLegacy>();
272272

273273
if (!ClearVirtRegs)
274-
AU.addPreserved<LiveDebugVariablesWrapperPass>();
274+
AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
275275

276276
MachineFunctionPass::getAnalysisUsage(AU);
277277
}
@@ -285,7 +285,7 @@ bool VirtRegRewriter::runOnMachineFunction(MachineFunction &fn) {
285285
LIS = &getAnalysis<LiveIntervalsWrapperPass>().getLIS();
286286
LRM = &getAnalysis<LiveRegMatrixWrapperLegacy>().getLRM();
287287
VRM = &getAnalysis<VirtRegMapWrapperLegacy>().getVRM();
288-
DebugVars = &getAnalysis<LiveDebugVariablesWrapperPass>().getLDV();
288+
DebugVars = &getAnalysis<LiveDebugVariablesWrapperLegacy>().getLDV();
289289
LLVM_DEBUG(dbgs() << "********** REWRITE VIRTUAL REGISTERS **********\n"
290290
<< "********** Function: " << MF->getName() << '\n');
291291
LLVM_DEBUG(VRM->dump());

llvm/lib/Target/LoongArch/LoongArchDeadRegisterDefinitions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class LoongArchDeadRegisterDefinitions : public MachineFunctionPass {
3737
AU.addPreserved<LiveIntervalsWrapperPass>();
3838
AU.addRequired<LiveIntervalsWrapperPass>();
3939
AU.addPreserved<SlotIndexesWrapperPass>();
40-
AU.addPreserved<LiveDebugVariablesWrapperPass>();
40+
AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
4141
AU.addPreserved<LiveStacks>();
4242
MachineFunctionPass::getAnalysisUsage(AU);
4343
}

llvm/lib/Target/RISCV/RISCVDeadRegisterDefinitions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class RISCVDeadRegisterDefinitions : public MachineFunctionPass {
3737
AU.addPreserved<LiveIntervalsWrapperPass>();
3838
AU.addRequired<LiveIntervalsWrapperPass>();
3939
AU.addPreserved<SlotIndexesWrapperPass>();
40-
AU.addPreserved<LiveDebugVariablesWrapperPass>();
40+
AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
4141
AU.addPreserved<LiveStacks>();
4242
MachineFunctionPass::getAnalysisUsage(AU);
4343
}

llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ class RISCVInsertVSETVLI : public MachineFunctionPass {
889889
AU.addUsedIfAvailable<LiveIntervalsWrapperPass>();
890890
AU.addPreserved<LiveIntervalsWrapperPass>();
891891
AU.addPreserved<SlotIndexesWrapperPass>();
892-
AU.addPreserved<LiveDebugVariablesWrapperPass>();
892+
AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
893893
AU.addPreserved<LiveStacks>();
894894

895895
MachineFunctionPass::getAnalysisUsage(AU);

0 commit comments

Comments
 (0)