Skip to content

Commit bd12ecb

Browse files
committed
[AMDGPU] Fix PC register mapping in wave32 mode
Summary: The PC_32 DWARF register is for a 32-bit process address space which we don't implement in AMDGCN; another way of putting this is that the size of the PC register is not a function of the wavefront size. If we ever implement a 32-bit process address space we will need to add two more DwarfFlavours i.e. we will need to represent the product of (wave32, wave64) x (64-bit address space, 32-bit address space). Tags: #llvm Differential Revision: https://reviews.llvm.org/D76732
1 parent 9002db0 commit bd12ecb

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

llvm/lib/Target/AMDGPU/SIRegisterInfo.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def FP_REG : SIReg<"fp", 0>;
103103
def SP_REG : SIReg<"sp", 0>;
104104

105105
// Pseudo-register to represent the program-counter DWARF register.
106-
def PC_REG : SIReg<"pc", 0>, DwarfRegNum<[16, 0]> {
106+
def PC_REG : SIReg<"pc", 0>, DwarfRegNum<[16, 16]> {
107107
// There is no physical register corresponding to a "program counter", but
108108
// we need to encode the concept in debug information in order to represent
109109
// things like the return value in unwind information.

llvm/unittests/MC/AMDGPU/DwarfRegMappings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ TEST(AMDGPUDwarfRegMappingTests, TestWave32DwarfRegMapping) {
6565
if (TM && TM->getMCRegisterInfo()) {
6666
auto MRI = TM->getMCRegisterInfo();
6767
// Wave32 Dwarf register mapping test numbers
68-
// PC_32 => 0, EXEC_MASK_32 => 1, S0 => 32, S63 => 95,
68+
// PC_64 => 16, EXEC_MASK_32 => 1, S0 => 32, S63 => 95,
6969
// S64 => 1088, S105 => 1129, V0 => 1536, V255 => 1791,
7070
// A0 => 2048, A255 => 2303
71-
for (int llvmReg : {0, 1, 32, 95, 1088, 1129, 1536, 1791, 2048, 2303}) {
71+
for (int llvmReg : {16, 1, 32, 95, 1088, 1129, 1536, 1791, 2048, 2303}) {
7272
MCRegister PCReg(*MRI->getLLVMRegNum(llvmReg, false));
7373
EXPECT_EQ(llvmReg, MRI->getDwarfRegNum(PCReg, false));
7474
}

llvm/unittests/Target/AMDGPU/DwarfRegMappings.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ TEST(AMDGPUDwarfRegMappingTests, TestWave32DwarfRegMapping) {
7575
auto MRI = ST.getRegisterInfo();
7676
if (MRI) {
7777
// Wave32 Dwarf register mapping test numbers
78-
// PC_32 => 0, EXEC_MASK_32 => 1, S0 => 32, S63 => 95,
78+
// PC_64 => 16, EXEC_MASK_32 => 1, S0 => 32, S63 => 95,
7979
// S64 => 1088, S105 => 1129, V0 => 1536, V255 => 1791,
8080
// A0 => 2048, A255 => 2303
81-
for (int llvmReg : {0, 1, 32, 95, 1088, 1129, 1536, 1791, 2048, 2303}) {
81+
for (int llvmReg :
82+
{16, 1, 32, 95, 1088, 1129, 1536, 1791, 2048, 2303}) {
8283
MCRegister PCReg(*MRI->getLLVMRegNum(llvmReg, false));
8384
EXPECT_EQ(llvmReg, MRI->getDwarfRegNum(PCReg, false));
8485
}

0 commit comments

Comments
 (0)