diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -5620,7 +5620,6 @@ DAG.AddDbgValue(SDV, false); continue; } - assert(!IsDbgDeclare && "DbgDeclare operand is not in memory?"); FuncInfo.ArgDbgValues.push_back( BuildMI(MF, DL, TII->get(TargetOpcode::DBG_VALUE), IsDbgDeclare, RegAndSize.first, Variable, *FragmentExpr)); diff --git a/llvm/test/CodeGen/AMDGPU/ptr-arg-dbg-value.ll b/llvm/test/CodeGen/AMDGPU/ptr-arg-dbg-value.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AMDGPU/ptr-arg-dbg-value.ll @@ -0,0 +1,51 @@ +; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 < %s | FileCheck %s + +; For AMDGPU the 64-bit pointer argument %arg will get split into two registers +; and for its llvm.dbg.declare, DAG should emit two DBG_VALUE instructions +; with the fragment expressions. + +%struct.A = type { [100 x i32] } + +define hidden void @ptr_arg_dbg_value(%struct.A* %arg) #0 !dbg !9 { +; CHECK-LABEL: ptr_arg_dbg_value: +; CHECK: ;DEBUG_VALUE: ptr_arg_dbg_value:a <- [DW_OP_LLVM_fragment 32 32] [$vgpr1+0] +; CHECK: ;DEBUG_VALUE: ptr_arg_dbg_value:a <- [DW_OP_LLVM_fragment 0 32] [$vgpr0+0] + call void @llvm.dbg.declare(metadata %struct.A* %arg, metadata !20, metadata !DIExpression()), !dbg !21 + %gep = getelementptr inbounds %struct.A, %struct.A* %arg, i32 0, i32 0, i32 99, !dbg !22 + store i32 1, i32* %gep, align 4, !dbg !23 + ret void, !dbg !24 +} + +declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 + +attributes #0 = { nounwind } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5, !6, !7} +!llvm.ident = !{!8} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 13.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) +!1 = !DIFile(filename: "example.cpp", directory: "temp") +!2 = !{} +!3 = !{i32 7, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{i32 7, !"uwtable", i32 1} +!7 = !{i32 7, !"frame-pointer", i32 2} +!8 = !{!"clang version 13.0.0"} +!9 = distinct !DISubprogram(name: "ptr_arg_dbg_value", linkageName: "_Z4ptr_arg_dbg_valuev", scope: !10, file: !10, line: 5, type: !11, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) +!10 = !DIFile(filename: "example.cpp", directory: "temp") +!11 = !DISubroutineType(types: !12) +!12 = !{!13} +!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !10, line: 1, size: 3200, flags: DIFlagTypePassByValue, elements: !14, identifier: "_ZTS1A") +!14 = !{!15} +!15 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !13, file: !10, line: 2, baseType: !16, size: 3200) +!16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !17, size: 3200, elements: !18) +!17 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!18 = !{!19} +!19 = !DISubrange(count: 100) +!20 = !DILocalVariable(name: "a", scope: !9, file: !10, line: 6, type: !13) +!21 = !DILocation(line: 6, column: 7, scope: !9) +!22 = !DILocation(line: 7, column: 7, scope: !9) +!23 = !DILocation(line: 7, column: 13, scope: !9) +!24 = !DILocation(line: 8, column: 5, scope: !9)