[llvm] [DirectX] Fix build breaks (PR #128556)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 24 11:27:46 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-directx

Author: Farzon Lotfi (farzonl)

<details>
<summary>Changes</summary>

1. Fix build break caused by #<!-- -->126772 by adding `writeDISubrangeType` stub to `DXILBitcodeWriter.cpp`
2. Fix build break caused by #<!-- -->128480 by adding implementation of pure virtual method `TargetSubtargetInfo::getRegisterInfo`

---
Full diff: https://github.com/llvm/llvm-project/pull/128556.diff


5 Files Affected:

- (modified) llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp (+4) 
- (modified) llvm/lib/Target/DirectX/DirectXInstrInfo.h (+2-1) 
- (modified) llvm/lib/Target/DirectX/DirectXRegisterInfo.cpp (+21) 
- (modified) llvm/lib/Target/DirectX/DirectXRegisterInfo.h (+8) 
- (modified) llvm/lib/Target/DirectX/DirectXSubtarget.h (+4) 


``````````diff
diff --git a/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp b/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
index 543fbd10db230..a65a619bfc9c3 100644
--- a/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
+++ b/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
@@ -243,6 +243,10 @@ class DXILBitcodeWriter {
   }
   void writeDIDerivedType(const DIDerivedType *N,
                           SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
+  void writeDISubrangeType(const DISubrangeType *N,
+                            SmallVectorImpl<uint64_t> &Record, unsigned Abbrev) {
+    llvm_unreachable("DXIL cannot contain DISubrangeType Nodes");
+  }
   void writeDICompositeType(const DICompositeType *N,
                             SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
   void writeDISubroutineType(const DISubroutineType *N,
diff --git a/llvm/lib/Target/DirectX/DirectXInstrInfo.h b/llvm/lib/Target/DirectX/DirectXInstrInfo.h
index 4fe79ee547fe1..e2c7036fc74a7 100644
--- a/llvm/lib/Target/DirectX/DirectXInstrInfo.h
+++ b/llvm/lib/Target/DirectX/DirectXInstrInfo.h
@@ -21,8 +21,9 @@
 
 namespace llvm {
 struct DirectXInstrInfo : public DirectXGenInstrInfo {
+  const DirectXRegisterInfo RI;
   explicit DirectXInstrInfo() : DirectXGenInstrInfo() {}
-
+  const DirectXRegisterInfo &getRegisterInfo() const { return RI; }
   ~DirectXInstrInfo() override;
 };
 } // namespace llvm
diff --git a/llvm/lib/Target/DirectX/DirectXRegisterInfo.cpp b/llvm/lib/Target/DirectX/DirectXRegisterInfo.cpp
index c54b494f37304..690a9afdd5e2a 100644
--- a/llvm/lib/Target/DirectX/DirectXRegisterInfo.cpp
+++ b/llvm/lib/Target/DirectX/DirectXRegisterInfo.cpp
@@ -22,3 +22,24 @@
 using namespace llvm;
 
 DirectXRegisterInfo::~DirectXRegisterInfo() {}
+
+const MCPhysReg *
+DirectXRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
+  return nullptr;
+}
+BitVector
+DirectXRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
+  return BitVector(getNumRegs());
+}
+
+bool DirectXRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
+                                              int SPAdj, unsigned FIOperandNum,
+                                              RegScavenger *RS) const {
+  return false;
+}
+
+// Debug information queries.
+Register
+DirectXRegisterInfo::getFrameRegister(const MachineFunction &MF) const {
+  return Register();
+}
diff --git a/llvm/lib/Target/DirectX/DirectXRegisterInfo.h b/llvm/lib/Target/DirectX/DirectXRegisterInfo.h
index 023c5c3ef337f..3e750bb4f89b2 100644
--- a/llvm/lib/Target/DirectX/DirectXRegisterInfo.h
+++ b/llvm/lib/Target/DirectX/DirectXRegisterInfo.h
@@ -22,6 +22,14 @@ namespace llvm {
 struct DirectXRegisterInfo : public DirectXGenRegisterInfo {
   DirectXRegisterInfo() : DirectXGenRegisterInfo(0) {}
   ~DirectXRegisterInfo();
+
+  const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;
+  BitVector getReservedRegs(const MachineFunction &MF) const override;
+  bool eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj,
+                           unsigned FIOperandNum,
+                           RegScavenger *RS = nullptr) const override;
+  // Debug information queries.
+  Register getFrameRegister(const MachineFunction &MF) const override;
 };
 } // namespace llvm
 
diff --git a/llvm/lib/Target/DirectX/DirectXSubtarget.h b/llvm/lib/Target/DirectX/DirectXSubtarget.h
index 464d05a0e1ffe..b2374caaf3cdf 100644
--- a/llvm/lib/Target/DirectX/DirectXSubtarget.h
+++ b/llvm/lib/Target/DirectX/DirectXSubtarget.h
@@ -49,6 +49,10 @@ class DirectXSubtarget : public DirectXGenSubtargetInfo {
   const DirectXFrameLowering *getFrameLowering() const override { return &FL; }
 
   const DirectXInstrInfo *getInstrInfo() const override { return &InstrInfo; }
+
+  const DirectXRegisterInfo *getRegisterInfo() const override {
+    return &InstrInfo.getRegisterInfo();
+  }
 };
 
 } // end namespace llvm

``````````

</details>


https://github.com/llvm/llvm-project/pull/128556


More information about the llvm-commits mailing list