Skip to content

Commit a355c2d

Browse files
authored
[DebugInfo][InferAddressSpaces] Fix the missing debug location update for the new addrspacecast (#97038)
Fix #97006 .
1 parent de5ff38 commit a355c2d

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ Value *InferAddressSpacesImpl::cloneInstructionWithNewAddressSpace(
642642
Type *NewPtrTy = getPtrOrVecOfPtrsWithNewAS(I->getType(), AS);
643643
auto *NewI = new AddrSpaceCastInst(I, NewPtrTy);
644644
NewI->insertAfter(I);
645+
NewI->setDebugLoc(I->getDebugLoc());
645646
return NewI;
646647
}
647648

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=infer-address-spaces -o - %s | FileCheck %s
2+
3+
; Check that InferAddressSpaces's cloneInstructionWithNewAddressSpace() propagates
4+
; the debug location to new addrspacecast instruction which casts `%p` in the following test.
5+
6+
@c0 = addrspace(4) global ptr poison
7+
8+
define float @generic_ptr_from_constant() !dbg !5 {
9+
; CHECK-LABEL: define float @generic_ptr_from_constant(
10+
; CHECK: [[TMP1:%.*]] = addrspacecast ptr [[P:%.*]] to ptr addrspace(1), !dbg [[DBG8:![0-9]+]]
11+
;
12+
%p = load ptr, ptr addrspace(4) @c0, align 8, !dbg !8
13+
%v = load float, ptr %p, align 4, !dbg !9
14+
ret float %v, !dbg !10
15+
}
16+
17+
!llvm.dbg.cu = !{!0}
18+
!llvm.debugify = !{!2, !3}
19+
!llvm.module.flags = !{!4}
20+
21+
; CHECK: [[DBG8]] = !DILocation(line: 1,
22+
;
23+
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
24+
!1 = !DIFile(filename: "temp.ll", directory: "/")
25+
!2 = !{i32 3}
26+
!3 = !{i32 0}
27+
!4 = !{i32 2, !"Debug Info Version", i32 3}
28+
!5 = distinct !DISubprogram(name: "generic_ptr_from_constant", linkageName: "generic_ptr_from_constant", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
29+
!6 = !DISubroutineType(types: !7)
30+
!7 = !{}
31+
!8 = !DILocation(line: 1, column: 1, scope: !5)
32+
!9 = !DILocation(line: 2, column: 1, scope: !5)
33+
!10 = !DILocation(line: 3, column: 1, scope: !5)

0 commit comments

Comments
 (0)