[llvm] db40592 - MachineFunction: Remove null check on TargetRegisterInfo (#128480)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 24 03:21:24 PST 2025
Author: Matt Arsenault
Date: 2025-02-24T18:21:20+07:00
New Revision: db40592de60f579afa18db3a06a4505c8e63de65
URL: https://github.com/llvm/llvm-project/commit/db40592de60f579afa18db3a06a4505c8e63de65
DIFF: https://github.com/llvm/llvm-project/commit/db40592de60f579afa18db3a06a4505c8e63de65.diff
LOG: MachineFunction: Remove null check on TargetRegisterInfo (#128480)
Targets are required to define this, it is not optional. Make the method
pure virtual to enforce this
Added:
Modified:
llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
llvm/lib/CodeGen/MachineFunction.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h b/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
index 76c94981e1afc..1230349956973 100644
--- a/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
@@ -124,9 +124,8 @@ class TargetSubtargetInfo : public MCSubtargetInfo {
virtual const LegalizerInfo *getLegalizerInfo() const { return nullptr; }
- /// getRegisterInfo - If register information is available, return it. If
- /// not, return null.
- virtual const TargetRegisterInfo *getRegisterInfo() const { return nullptr; }
+ /// Return the target's register information.
+ virtual const TargetRegisterInfo *getRegisterInfo() const = 0;
/// If the information for the register banks is available, return it.
/// Otherwise return nullptr.
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index 6e0342a763d15..eb0a16732b058 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -189,10 +189,7 @@ void MachineFunction::init() {
// Assume the function starts in SSA form with correct liveness.
Properties.set(MachineFunctionProperties::Property::IsSSA);
Properties.set(MachineFunctionProperties::Property::TracksLiveness);
- if (STI->getRegisterInfo())
- RegInfo = new (Allocator) MachineRegisterInfo(this);
- else
- RegInfo = nullptr;
+ RegInfo = new (Allocator) MachineRegisterInfo(this);
MFInfo = nullptr;
More information about the llvm-commits
mailing list