[llvm] 68f163d - [AMDGPU] Print DWARF register numbers in AMDGPUInstPrinter
Scott Linder via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 17 16:43:36 PDT 2020
Author: Scott Linder
Date: 2020-03-17T19:42:10-04:00
New Revision: 68f163df0ec59082688edd526fe6b30bac95e03e
URL: https://github.com/llvm/llvm-project/commit/68f163df0ec59082688edd526fe6b30bac95e03e
DIFF: https://github.com/llvm/llvm-project/commit/68f163df0ec59082688edd526fe6b30bac95e03e.diff
LOG: [AMDGPU] Print DWARF register numbers in AMDGPUInstPrinter
Summary:
Explanation is in a comment in the diff, but essentially printing a
physical register name here is ambiguous. Until we can implement
printing a DWARF register name here just use the encoding directly.
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D76253
Added:
Modified:
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp
llvm/test/DebugInfo/AMDGPU/print-reg-name.s
Removed:
llvm/test/DebugInfo/AMDGPU/register-mapping.s
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp
index 9d5d2db4bd6c..df843f4034ef 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp
@@ -27,7 +27,19 @@ using namespace llvm;
using namespace llvm::AMDGPU;
void AMDGPUInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
- OS << getRegisterName(RegNo);
+ // FIXME: The current implementation of
+ // AsmParser::parseRegisterOrRegisterNumber in MC implies we either emit this
+ // as an integer or we provide a name which represents a physical register.
+ // For CFI instructions we really want to emit a name for the DWARF register
+ // instead, because there may be multiple DWARF registers corresponding to a
+ // single physical register. One case where this problem manifests is with
+ // wave32/wave64 where using the physical register name is ambiguous: if we
+ // write e.g. `.cfi_undefined v0` we lose information about the wavefront
+ // size which we need to encode the register in the final DWARF. Ideally we
+ // would extend MC to support parsing DWARF register names so we could do
+ // something like `.cfi_undefined dwarf_wave32_v0`. For now we just live with
+ // non-pretty DWARF register names in assembly text.
+ OS << RegNo;
}
void AMDGPUInstPrinter::printInst(const MCInst *MI, uint64_t Address,
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp
index 9644e66fda4e..9ac1b1badee1 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp
@@ -43,6 +43,7 @@ AMDGPUMCAsmInfo::AMDGPUMCAsmInfo(const Triple &TT,
WeakRefDirective = ".weakref\t";
//===--- Dwarf Emission Directives -----------------------------------===//
SupportsDebugInformation = true;
+ DwarfRegNumForCFI = true;
}
bool AMDGPUMCAsmInfo::shouldOmitSectionDirective(StringRef SectionName) const {
diff --git a/llvm/test/DebugInfo/AMDGPU/print-reg-name.s b/llvm/test/DebugInfo/AMDGPU/print-reg-name.s
index 8c2ae89ce428..fdd2c59bdd16 100644
--- a/llvm/test/DebugInfo/AMDGPU/print-reg-name.s
+++ b/llvm/test/DebugInfo/AMDGPU/print-reg-name.s
@@ -1,10 +1,16 @@
; RUN: llvm-mc -triple=amdgcn-amd-amdhsa -mcpu=gfx900 -filetype=asm %s | FileCheck %s
-; Check that we can print symbolic register operands in CFI instructions.
+; FIXME: Currently we can't print register names in CFI directives
+; without extending MC to support DWARF register names that are distinct
+; from physical register names.
.text
f:
.cfi_startproc
-; CHECK: .cfi_undefined s0
-.cfi_undefined s0
+; CHECK: .cfi_undefined 2560
+.cfi_undefined 2560
+; FIXME: Until we implement a distinct set of DWARF register names we
+; will continue to parse physical registers and pick an arbitrary encoding.
+; CHECK: .cfi_undefined 2560
+.cfi_undefined v0
.cfi_endproc
diff --git a/llvm/test/DebugInfo/AMDGPU/register-mapping.s b/llvm/test/DebugInfo/AMDGPU/register-mapping.s
deleted file mode 100644
index 5d967c36eb20..000000000000
--- a/llvm/test/DebugInfo/AMDGPU/register-mapping.s
+++ /dev/null
@@ -1,37 +0,0 @@
-; RUN: llvm-mc -triple=amdgcn-amd-amdhsa -mcpu=gfx1010 -filetype=obj %s | llvm-dwarfdump -debug-frame - | FileCheck %s
-
-; Check that we implement the DWARF register mapping.
-
-.text
-f:
-.cfi_startproc
-; CHECK: CIE
-; CHECK: Return address column: 16
-
-; CHECK: FDE
-; CHECK: DW_CFA_undefined: reg16
-.cfi_undefined pc
-; CHECK: DW_CFA_undefined: reg17
-.cfi_undefined exec
-
-; CHECK: DW_CFA_undefined: reg32
-.cfi_undefined s0
-; CHECK: DW_CFA_undefined: reg95
-.cfi_undefined s63
-
-; CHECK: DW_CFA_undefined: reg1088
-.cfi_undefined s64
-; CHECK: DW_CFA_undefined: reg1129
-.cfi_undefined s105
-
-; CHECK: DW_CFA_undefined: reg2560
-.cfi_undefined v0
-; CHECK: DW_CFA_undefined: reg2815
-.cfi_undefined v255
-
-; CHECK: DW_CFA_undefined: reg3072
-.cfi_undefined a0
-; CHECK: DW_CFA_undefined: reg3327
-.cfi_undefined a255
-
-.cfi_endproc
More information about the llvm-commits
mailing list