Skip to content

Commit db40592

Browse files
authored
MachineFunction: Remove null check on TargetRegisterInfo (llvm#128480)
Targets are required to define this, it is not optional. Make the method pure virtual to enforce this
1 parent 7de6492 commit db40592

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

llvm/include/llvm/CodeGen/TargetSubtargetInfo.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@ class TargetSubtargetInfo : public MCSubtargetInfo {
124124

125125
virtual const LegalizerInfo *getLegalizerInfo() const { return nullptr; }
126126

127-
/// getRegisterInfo - If register information is available, return it. If
128-
/// not, return null.
129-
virtual const TargetRegisterInfo *getRegisterInfo() const { return nullptr; }
127+
/// Return the target's register information.
128+
virtual const TargetRegisterInfo *getRegisterInfo() const = 0;
130129

131130
/// If the information for the register banks is available, return it.
132131
/// Otherwise return nullptr.

llvm/lib/CodeGen/MachineFunction.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,7 @@ void MachineFunction::init() {
189189
// Assume the function starts in SSA form with correct liveness.
190190
Properties.set(MachineFunctionProperties::Property::IsSSA);
191191
Properties.set(MachineFunctionProperties::Property::TracksLiveness);
192-
if (STI->getRegisterInfo())
193-
RegInfo = new (Allocator) MachineRegisterInfo(this);
194-
else
195-
RegInfo = nullptr;
192+
RegInfo = new (Allocator) MachineRegisterInfo(this);
196193

197194
MFInfo = nullptr;
198195

0 commit comments

Comments
 (0)