Skip to content

Commit 1ce5e29

Browse files
committed
Fix invalidate and expose LDVImpl to .h
1 parent bc70f89 commit 1ce5e29

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

llvm/include/llvm/CodeGen/LiveDebugVariables.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@ namespace llvm {
3030
template <typename T> class ArrayRef;
3131
class LiveIntervals;
3232
class VirtRegMap;
33+
class LDVImpl;
3334

3435
class LiveDebugVariables {
3536
private:
36-
struct Deleter {
37-
void operator()(void *Ptr) const;
38-
};
39-
std::unique_ptr<void, Deleter> PImpl;
37+
std::unique_ptr<LDVImpl> PImpl;
4038

4139
public:
4240
LiveDebugVariables() = default;

llvm/lib/CodeGen/LiveDebugVariables.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,6 @@ using BlockSkipInstsMap =
277277

278278
namespace {
279279

280-
class LDVImpl;
281-
282280
/// A user value is a part of a debug info user variable.
283281
///
284282
/// A DBG_VALUE instruction notes that (a sub-register of) a virtual register
@@ -531,6 +529,10 @@ class UserLabel {
531529
void print(raw_ostream &, const TargetRegisterInfo *);
532530
};
533531

532+
} // end anonymous namespace
533+
534+
namespace llvm {
535+
534536
/// Implementation of the LiveDebugVariables pass.
535537
class LDVImpl {
536538
LocMap::Allocator allocator;
@@ -673,7 +675,7 @@ class LDVImpl {
673675
void print(raw_ostream&);
674676
};
675677

676-
} // end anonymous namespace
678+
} // namespace llvm
677679

678680
static void printDebugLoc(const DebugLoc &DL, raw_ostream &CommentOS,
679681
const LLVMContext &Ctx) {
@@ -1325,13 +1327,9 @@ LiveDebugVariablesPrinterPass::run(MachineFunction &MF,
13251327
return PreservedAnalyses::all();
13261328
}
13271329

1328-
void LiveDebugVariables::Deleter::operator()(void *Ptr) const {
1329-
delete static_cast<LDVImpl *>(Ptr);
1330-
}
1331-
13321330
void LiveDebugVariables::releaseMemory() {
13331331
if (PImpl)
1334-
static_cast<LDVImpl *>(PImpl.get())->clear();
1332+
PImpl->clear();
13351333
}
13361334

13371335
bool LiveDebugVariables::invalidate(
@@ -1341,7 +1339,7 @@ bool LiveDebugVariables::invalidate(
13411339
// Some architectures split the register allocation into multiple phases based
13421340
// on register classes. This requires preserving analyses between the phases
13431341
// by default.
1344-
return PAC.preservedWhenStateless();
1342+
return !PAC.preservedWhenStateless();
13451343
}
13461344

13471345
void LiveDebugVariables::analyze(MachineFunction &MF, LiveIntervals *LIS) {
@@ -1357,7 +1355,7 @@ void LiveDebugVariables::analyze(MachineFunction &MF, LiveIntervals *LIS) {
13571355
// Have we been asked to track variable locations using instruction
13581356
// referencing?
13591357
bool InstrRef = MF.useDebugInstrRef();
1360-
static_cast<LDVImpl *>(PImpl.get())->runOnMachineFunction(MF, InstrRef);
1358+
PImpl->runOnMachineFunction(MF, InstrRef);
13611359
}
13621360

13631361
//===----------------------------------------------------------------------===//
@@ -1540,7 +1538,7 @@ void LDVImpl::splitRegister(Register OldReg, ArrayRef<Register> NewRegs) {
15401538
void LiveDebugVariables::
15411539
splitRegister(Register OldReg, ArrayRef<Register> NewRegs, LiveIntervals &LIS) {
15421540
if (PImpl)
1543-
static_cast<LDVImpl *>(PImpl.get())->splitRegister(OldReg, NewRegs);
1541+
PImpl->splitRegister(OldReg, NewRegs);
15441542
}
15451543

15461544
void UserValue::rewriteLocations(VirtRegMap &VRM, const MachineFunction &MF,
@@ -1992,7 +1990,7 @@ void LDVImpl::emitDebugValues(VirtRegMap *VRM) {
19921990

19931991
void LiveDebugVariables::emitDebugValues(VirtRegMap *VRM) {
19941992
if (PImpl)
1995-
static_cast<LDVImpl *>(PImpl.get())->emitDebugValues(VRM);
1993+
PImpl->emitDebugValues(VRM);
19961994
}
19971995

19981996
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
@@ -2001,5 +1999,5 @@ LLVM_DUMP_METHOD void LiveDebugVariables::dump() const { print(dbgs()); }
20011999

20022000
void LiveDebugVariables::print(raw_ostream &OS) const {
20032001
if (PImpl)
2004-
static_cast<LDVImpl *>(PImpl.get())->print(OS);
2002+
PImpl->print(OS);
20052003
}

0 commit comments

Comments
 (0)