Skip to content

Commit 7673d24

Browse files
author
Dan Gohman
committed
Use TargetRegisterInfo for printing MachineOperand register comments
Several places in AsmPrinter.cpp print comments describing MachineOperand registers using MCRegisterInfo, which uses MCOperand-oriented names. This doesn't work for targets that use virtual registers exclusively, as WebAssembly does, since virtual registers are represented and printed differently. This patch preserves what seems to be the spirit of r229978, avoiding the use of TM.getSubtargetImpl(), while still using MachineOperand-oriented printing for MachineOperands. Differential Revision: http://reviews.llvm.org/D14709 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253338 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 08e6ab9 commit 7673d24

9 files changed

+25
-17
lines changed

lib/CodeGen/AsmPrinter/AsmPrinter.cpp

+15-7
Original file line numberDiff line numberDiff line change
@@ -724,19 +724,27 @@ static void emitComments(const MachineInstr &MI, raw_ostream &CommentOS) {
724724
/// that is an implicit def.
725725
void AsmPrinter::emitImplicitDef(const MachineInstr *MI) const {
726726
unsigned RegNo = MI->getOperand(0).getReg();
727-
OutStreamer->AddComment(Twine("implicit-def: ") +
728-
MMI->getContext().getRegisterInfo()->getName(RegNo));
727+
728+
SmallString<128> Str;
729+
raw_svector_ostream OS(Str);
730+
OS << "implicit-def: "
731+
<< PrintReg(RegNo, MF->getSubtarget().getRegisterInfo());
732+
733+
OutStreamer->AddComment(OS.str());
729734
OutStreamer->AddBlankLine();
730735
}
731736

732737
static void emitKill(const MachineInstr *MI, AsmPrinter &AP) {
733-
std::string Str = "kill:";
738+
std::string Str;
739+
raw_string_ostream OS(Str);
740+
OS << "kill:";
734741
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
735742
const MachineOperand &Op = MI->getOperand(i);
736743
assert(Op.isReg() && "KILL instruction must have only register operands");
737-
Str += ' ';
738-
Str += AP.MMI->getContext().getRegisterInfo()->getName(Op.getReg());
739-
Str += (Op.isDef() ? "<def>" : "<kill>");
744+
OS << ' '
745+
<< PrintReg(Op.getReg(),
746+
AP.MF->getSubtarget().getRegisterInfo())
747+
<< (Op.isDef() ? "<def>" : "<kill>");
740748
}
741749
AP.OutStreamer->AddComment(Str);
742750
AP.OutStreamer->AddBlankLine();
@@ -811,7 +819,7 @@ static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) {
811819
}
812820
if (Deref)
813821
OS << '[';
814-
OS << AP.MMI->getContext().getRegisterInfo()->getName(Reg);
822+
OS << PrintReg(Reg, AP.MF->getSubtarget().getRegisterInfo());
815823
}
816824

817825
if (Deref)

test/CodeGen/AMDGPU/llvm.dbg.value.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
; CHECK-LABEL: {{^}}test_debug_value:
44
; CHECK: s_load_dwordx2
5-
; CHECK: DEBUG_VALUE: test_debug_value:globalptr_arg <- SGPR0_SGPR1
5+
; CHECK: DEBUG_VALUE: test_debug_value:globalptr_arg <- %SGPR0_SGPR1
66
; CHECK: buffer_store_dword
77
; CHECK: s_endpgm
88
define void @test_debug_value(i32 addrspace(1)* nocapture %globalptr_arg) #0 !dbg !4 {

test/CodeGen/ARM/debug-info-arg.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ define void @foo(%struct.tag_s* nocapture %this, %struct.tag_s* %c, i64 %x, i64
1111
tail call void @llvm.dbg.value(metadata %struct.tag_s* %c, i64 0, metadata !13, metadata !DIExpression()), !dbg !21
1212
tail call void @llvm.dbg.value(metadata i64 %x, i64 0, metadata !14, metadata !DIExpression()), !dbg !22
1313
tail call void @llvm.dbg.value(metadata i64 %y, i64 0, metadata !17, metadata !DIExpression()), !dbg !23
14-
;CHECK: @DEBUG_VALUE: foo:y <- [R7+8]
14+
;CHECK: @DEBUG_VALUE: foo:y <- [%R7+8]
1515
tail call void @llvm.dbg.value(metadata %struct.tag_s* %ptr1, i64 0, metadata !18, metadata !DIExpression()), !dbg !24
1616
tail call void @llvm.dbg.value(metadata %struct.tag_s* %ptr2, i64 0, metadata !19, metadata !DIExpression()), !dbg !25
1717
%1 = icmp eq %struct.tag_s* %c, null, !dbg !26

test/CodeGen/ARM/debug-info-blocks.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; RUN: llc -O0 < %s | FileCheck %s
2-
; CHECK: @DEBUG_VALUE: foobar_func_block_invoke_0:mydata <- [SP+{{[0-9]+}}]
2+
; CHECK: @DEBUG_VALUE: foobar_func_block_invoke_0:mydata <- [%SP+{{[0-9]+}}]
33
; Radar 9331779
44
target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:64-v128:32:128-a0:0:32-n32"
55
target triple = "thumbv7-apple-ios"

test/CodeGen/ARM/debug-info-branch-folding.ll

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ target triple = "thumbv7-apple-macosx10.6.7"
66
;CHECK-NEXT: Ltmp1
77
;CHECK-NEXT: LBB0_1
88

9-
;CHECK:@DEBUG_VALUE: x <- Q4{{$}}
10-
;CHECK-NEXT:@DEBUG_VALUE: y <- Q4{{$}}
9+
;CHECK:@DEBUG_VALUE: x <- %Q4{{$}}
10+
;CHECK-NEXT:@DEBUG_VALUE: y <- %Q4{{$}}
1111

1212

1313
@.str = external constant [13 x i8]

test/CodeGen/BPF/sockex2.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ flow_dissector.exit.thread: ; preds = %86, %12, %196, %199
311311
; CHECK-LABEL: bpf_prog2:
312312
; CHECK: ldabs_h r0, r6.data + 12 # encoding: [0x28,0x00,0x00,0x00,0x0c,0x00,0x00,0x00]
313313
; CHECK: ldabs_h r0, r6.data + 16 # encoding: [0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00]
314-
; CHECK: implicit-def: R1
314+
; CHECK: implicit-def: %R1
315315
; CHECK: ld_64 r1
316316
; CHECK-NOT: ori
317317
; CHECK: call 1 # encoding: [0x85,0x00,0x00,0x00,0x01,0x00,0x00,0x00]

test/CodeGen/Mips/llvm-ir/call.ll

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ declare hidden void @undef_double(i32 %this, double %volume) unnamed_addr align
176176

177177
define hidden void @thunk_undef_double(i32 %this, double %volume) unnamed_addr align 2 {
178178
; ALL-LABEL: thunk_undef_double:
179-
; O32: # implicit-def: A2
180-
; O32: # implicit-def: A3
179+
; O32: # implicit-def: %A2
180+
; O32: # implicit-def: %A3
181181
; ALL: jr $25
182182
tail call void @undef_double(i32 undef, double undef) #8
183183
ret void

test/CodeGen/X86/2010-05-28-Crash.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ entry:
4646
!18 = !DIFile(filename: "f.c", directory: "/tmp")
4747
!19 = !{}
4848

49-
;CHECK: DEBUG_VALUE: bar:x <- E
49+
;CHECK: DEBUG_VALUE: bar:x <- %E
5050
;CHECK: Ltmp
5151
;CHECK: DEBUG_VALUE: foo:y <- 1{{$}}
5252
!20 = !{i32 1, !"Debug Info Version", i32 3}

test/CodeGen/X86/2010-06-01-DeadArg-DbgInfo.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ target triple = "x86_64-apple-darwin10.2"
88
@llvm.used = appending global [1 x i8*] [i8* bitcast (i32 (%struct.foo*, i32)* @_ZN3foo3bazEi to i8*)], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0]
99

1010
define i32 @_ZN3foo3bazEi(%struct.foo* nocapture %this, i32 %x) nounwind readnone optsize noinline ssp align 2 !dbg !8 {
11-
;CHECK: DEBUG_VALUE: baz:this <- RDI{{$}}
11+
;CHECK: DEBUG_VALUE: baz:this <- %RDI{{$}}
1212
entry:
1313
tail call void @llvm.dbg.value(metadata %struct.foo* %this, i64 0, metadata !15, metadata !DIExpression()), !dbg !DILocation(scope: !8)
1414
tail call void @llvm.dbg.value(metadata i32 %x, i64 0, metadata !16, metadata !DIExpression()), !dbg !DILocation(scope: !8)

0 commit comments

Comments
 (0)