Skip to content

[DirectX] Fix build breaks #128556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ class DXILBitcodeWriter {
}
void writeDIDerivedType(const DIDerivedType *N,
SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
void writeDISubrangeType(const DISubrangeType *N,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a virtual function impl? It'd be great if this file used "override". (Probably out of scope for this change)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No its caused by HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DISubrangeType) in llvm/include/llvm/IR/Metadata.def line 121. This is because llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp uses Metadata.def in DXILBitcodeWriter::writeMetadataRecords

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,
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Target/DirectX/DirectXInstrInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions llvm/lib/Target/DirectX/DirectXRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
8 changes: 8 additions & 0 deletions llvm/lib/Target/DirectX/DirectXRegisterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ namespace llvm {
struct DirectXRegisterInfo : public DirectXGenRegisterInfo {
DirectXRegisterInfo() : DirectXGenRegisterInfo(0) {}
~DirectXRegisterInfo();

const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to implement these overrides to be able to create an instance of DirectXRegisterInfo in llvm/lib/Target/DirectX/DirectXInstrInfo.h

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

Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/DirectX/DirectXSubtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading