Skip to content

Commit f2b253b

Browse files
authored
[SelectionDAG] Fix an incorrect DebugLoc on a COPY (#122963)
Fixes: SWDEV-502134
1 parent acde3f7 commit f2b253b

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,9 @@ InstrEmitter::AddRegisterOperand(MachineInstrBuilder &MIB,
351351
OpRC = TRI->getAllocatableClass(OpRC);
352352
assert(OpRC && "Constraints cannot be fulfilled for allocation");
353353
Register NewVReg = MRI->createVirtualRegister(OpRC);
354-
BuildMI(*MBB, InsertPos, Op.getNode()->getDebugLoc(),
355-
TII->get(TargetOpcode::COPY), NewVReg).addReg(VReg);
354+
BuildMI(*MBB, InsertPos, MIB->getDebugLoc(),
355+
TII->get(TargetOpcode::COPY), NewVReg)
356+
.addReg(VReg);
356357
VReg = NewVReg;
357358
} else {
358359
assert(ConstrainedRC->isAllocatable() &&
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1030 < %s | FileCheck -check-prefix=GCN %s
3+
4+
; Verify that the debug locations in this function are correct, in particular
5+
; that the location for %cast doesn't appear in the block of %lab.
6+
7+
define void @_Z12lane_pc_testj() #0 !dbg !9 {
8+
; GCN-LABEL: _Z12lane_pc_testj:
9+
; GCN: .Lfunc_begin0:
10+
; GCN-NEXT: .file 0 "/" "t.cpp"
11+
; GCN-NEXT: .loc 0 3 0 ; t.cpp:3:0
12+
; GCN-NEXT: .cfi_sections .debug_frame
13+
; GCN-NEXT: .cfi_startproc
14+
; GCN-NEXT: ; %bb.0:
15+
; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
16+
; GCN-NEXT: ; %bb.1: ; %lab
17+
; GCN-NEXT: .Ltmp0:
18+
; GCN-NEXT: .loc 0 12 1 prologue_end ; t.cpp:12:1
19+
; GCN-NEXT: s_mov_b64 s[4:5], src_private_base
20+
; GCN-NEXT: s_mov_b32 s6, 32
21+
; GCN-NEXT: s_lshr_b64 s[4:5], s[4:5], s6
22+
; GCN-NEXT: s_mov_b64 s[6:7], 0
23+
; GCN-NEXT: s_mov_b32 s5, -1
24+
; GCN-NEXT: s_lshr_b32 s8, s32, 5
25+
; GCN-NEXT: s_cmp_lg_u32 s8, s5
26+
; GCN-NEXT: s_cselect_b32 s5, s4, s7
27+
; GCN-NEXT: s_cselect_b32 s4, s8, s6
28+
; GCN-NEXT: v_mov_b32_e32 v2, 0
29+
; GCN-NEXT: .loc 0 13 1 ; t.cpp:13:1
30+
; GCN-NEXT: v_mov_b32_e32 v0, s4
31+
; GCN-NEXT: v_mov_b32_e32 v1, s5
32+
; GCN-NEXT: flat_store_dword v[0:1], v2
33+
; GCN-NEXT: v_mov_b32_e32 v2, 1
34+
; GCN-NEXT: .loc 0 14 1 ; t.cpp:14:1
35+
; GCN-NEXT: v_mov_b32_e32 v0, s4
36+
; GCN-NEXT: v_mov_b32_e32 v1, s5
37+
; GCN-NEXT: flat_store_dword v[0:1], v2
38+
; GCN-NEXT: s_waitcnt lgkmcnt(0)
39+
; GCN-NEXT: s_setpc_b64 s[30:31]
40+
; GCN-NEXT: .Ltmp1:
41+
%alloc = alloca i32, align 4, addrspace(5)
42+
%cast = addrspacecast ptr addrspace(5) %alloc to ptr, !dbg !12
43+
br label %lab
44+
45+
lab:
46+
store i32 0, ptr %cast, align 4, !dbg !13
47+
store i32 1, ptr %cast, align 4, !dbg !14
48+
ret void
49+
}
50+
51+
attributes #0 = { noinline optnone }
52+
53+
!llvm.dbg.cu = !{!0}
54+
!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
55+
56+
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 20.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
57+
!1 = !DIFile(filename: "t.cpp", directory: "/")
58+
!2 = !{i32 1, !"amdhsa_code_object_version", i32 500}
59+
!3 = !{i32 1, !"amdgpu_printf_kind", !"hostcall"}
60+
!4 = !{i32 7, !"Dwarf Version", i32 5}
61+
!5 = !{i32 2, !"Debug Info Version", i32 3}
62+
!6 = !{i32 1, !"wchar_size", i32 4}
63+
!7 = !{i32 8, !"PIC Level", i32 2}
64+
!8 = !{i32 7, !"frame-pointer", i32 2}
65+
!9 = distinct !DISubprogram(name: "lane_pc_test", linkageName: "_Z12lane_pc_testj", scope: !1, file: !1, line: 1, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, type: !10, unit: !0)
66+
!10 = !DISubroutineType(types: !11)
67+
!11 = !{}
68+
!12 = !DILocation(line: 12, column: 1, scope: !9)
69+
!13 = !DILocation(line: 13, column: 1, scope: !9)
70+
!14 = !DILocation(line: 14, column: 1, scope: !9)

0 commit comments

Comments
 (0)