-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[DebugInfo][InferAddressSpaces] Fix the missing debug location update for the new addrspacecast #97038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DebugInfo][InferAddressSpaces] Fix the missing debug location update for the new addrspacecast #97038
Conversation
@llvm/pr-subscribers-backend-amdgpu @llvm/pr-subscribers-llvm-transforms Author: Shan Huang (Apochens) ChangesFix #97006 . Full diff: https://github.com/llvm/llvm-project/pull/97038.diff 2 Files Affected:
diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
index fbefd0e9368b2..be4da00ef85b4 100644
--- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
+++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
@@ -642,6 +642,7 @@ Value *InferAddressSpacesImpl::cloneInstructionWithNewAddressSpace(
Type *NewPtrTy = getPtrOrVecOfPtrsWithNewAS(I->getType(), AS);
auto *NewI = new AddrSpaceCastInst(I, NewPtrTy);
NewI->insertAfter(I);
+ NewI->setDebugLoc(I->getDebugLoc());
return NewI;
}
diff --git a/llvm/test/Transforms/InferAddressSpaces/AMDGPU/preserving-debugloc-addrspacecast.ll b/llvm/test/Transforms/InferAddressSpaces/AMDGPU/preserving-debugloc-addrspacecast.ll
new file mode 100644
index 0000000000000..cf89eeb713e5c
--- /dev/null
+++ b/llvm/test/Transforms/InferAddressSpaces/AMDGPU/preserving-debugloc-addrspacecast.ll
@@ -0,0 +1,34 @@
+; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=infer-address-spaces -o - %s | FileCheck %s
+
+; Check that InferAddressSpaces's cloneInstructionWithNewAddressSpace() propagates
+; the debug location to new addrspacecast instruction which casts `%p` in the following test.
+
+@c0 = addrspace(4) global ptr undef
+
+define float @generic_ptr_from_constant() !dbg !5 {
+; CHECK-LABEL: define float @generic_ptr_from_constant(
+; CHECK: [[TMP1:%.*]] = addrspacecast ptr [[P:%.*]] to ptr addrspace(1), !dbg [[DBG8:![0-9]+]]
+;
+ %p = load ptr, ptr addrspace(4) @c0, align 8, !dbg !8
+ %v = load float, ptr %p, align 4, !dbg !9
+ ret float %v, !dbg !10
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.debugify = !{!2, !3}
+!llvm.module.flags = !{!4}
+
+; CHECK: [[DBG8]] = !DILocation(line: 1,
+;
+!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
+!1 = !DIFile(filename: "temp.ll", directory: "/")
+!2 = !{i32 3}
+!3 = !{i32 0}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!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)
+!6 = !DISubroutineType(types: !7)
+!7 = !{}
+!8 = !DILocation(line: 1, column: 1, scope: !5)
+!9 = !DILocation(line: 2, column: 1, scope: !5)
+!10 = !DILocation(line: 3, column: 1, scope: !5)
+
|
llvm/test/Transforms/InferAddressSpaces/AMDGPU/preserving-debugloc-addrspacecast.ll
Outdated
Show resolved
Hide resolved
!8 = !DILocation(line: 1, column: 1, scope: !5) | ||
!9 = !DILocation(line: 2, column: 1, scope: !5) | ||
!10 = !DILocation(line: 3, column: 1, scope: !5) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
llvm/test/Transforms/InferAddressSpaces/AMDGPU/preserving-debugloc-addrspacecast.ll
Outdated
Show resolved
Hide resolved
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/51/builds/794 Here is the relevant piece of the build log for the reference:
|
… for the new addrspacecast (llvm#97038) Fix llvm#97006 .
… for the new addrspacecast (llvm#97038) Fix llvm#97006 .
Fix #97006 .