Index: llvm/lib/IR/Verifier.cpp =================================================================== --- llvm/lib/IR/Verifier.cpp +++ llvm/lib/IR/Verifier.cpp @@ -6284,6 +6284,20 @@ CheckDI(isType(Var->getRawType()), "invalid type ref", Var, Var->getRawType()); verifyFnArgs(DII); + + if (auto *Declare = dyn_cast(&DII)) { + if (auto *Alloca = dyn_cast_or_null(Declare->getAddress())) { + DIExpression *Expr = Declare->getExpression(); + std::optional FragSize = Declare->getFragmentSizeInBits(); + std::optional AllocSize = Alloca->getAllocationSizeInBits(DL); + if (FragSize && AllocSize && !AllocSize->isScalable() && + !Expr->isComplex()) { + CheckDI(*FragSize <= AllocSize->getFixedValue(), + "llvm.dbg.declare has larger fragment size than alloca size ", + &DII); + } + } + } } void Verifier::visitDbgLabelIntrinsic(StringRef Kind, DbgLabelInst &DLI) { Index: llvm/test/CodeGen/ARM/stack-frame-layout-remarks.ll =================================================================== --- llvm/test/CodeGen/ARM/stack-frame-layout-remarks.ll +++ llvm/test/CodeGen/ARM/stack-frame-layout-remarks.ll @@ -236,19 +236,19 @@ !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !4, splitDebugInlining: false, nameTableKind: None) !3 = !DIFile(filename: "dot.c", directory: "") !4 = !{!5, !6, !10, !13} -!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Array", file: !3, line: 3, size: 128, elements: !8) +!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 32) +!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32) +!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Array", file: !3, line: 3, size: 64, elements: !8) !8 = !{!9, !12} -!9 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !7, file: !3, line: 4, baseType: !10, size: 64) -!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64) +!9 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !7, file: !3, line: 4, baseType: !10, size: 32) +!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 32) !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!12 = !DIDerivedType(tag: DW_TAG_member, name: "size", scope: !7, file: !3, line: 5, baseType: !11, size: 32, offset: 64) -!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64) -!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Result", file: !3, line: 8, size: 128, elements: !15) +!12 = !DIDerivedType(tag: DW_TAG_member, name: "size", scope: !7, file: !3, line: 5, baseType: !11, size: 32, offset: 32) +!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 32) +!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Result", file: !3, line: 8, size: 64, elements: !15) !15 = !{!16, !17} -!16 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !14, file: !3, line: 9, baseType: !6, size: 64) -!17 = !DIDerivedType(tag: DW_TAG_member, name: "sum", scope: !14, file: !3, line: 10, baseType: !11, size: 32, offset: 64) +!16 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !14, file: !3, line: 9, baseType: !6, size: 32) +!17 = !DIDerivedType(tag: DW_TAG_member, name: "sum", scope: !14, file: !3, line: 10, baseType: !11, size: 32, offset: 32) !18 = !{i32 7, !"Dwarf Version", i32 5} !19 = !{i32 2, !"Debug Info Version", i32 3} !20 = !{i32 1, !"wchar_size", i32 4} Index: llvm/test/CodeGen/BPF/warn-stack.ll =================================================================== --- llvm/test/CodeGen/BPF/warn-stack.ll +++ llvm/test/CodeGen/BPF/warn-stack.ll @@ -2,11 +2,11 @@ ;; CHECK-NOT: nowarn define void @nowarn() local_unnamed_addr #0 !dbg !6 { - %1 = alloca [504 x i8], align 1 - call void @llvm.lifetime.start.p0(i64 504, ptr nonnull %1) #4, !dbg !15 + %1 = alloca [511 x i8], align 1 + call void @llvm.lifetime.start.p0(i64 511, ptr nonnull %1) #4, !dbg !15 tail call void @llvm.dbg.declare(metadata ptr %1, metadata !10, metadata !16), !dbg !17 call void @doit(ptr nonnull %1) #4, !dbg !18 - call void @llvm.lifetime.end.p0(i64 504, ptr nonnull %1) #4, !dbg !19 + call void @llvm.lifetime.end.p0(i64 511, ptr nonnull %1) #4, !dbg !19 ret void, !dbg !19 } Index: llvm/test/CodeGen/X86/stack-frame-layout-remarks-32.ll =================================================================== --- llvm/test/CodeGen/X86/stack-frame-layout-remarks-32.ll +++ llvm/test/CodeGen/X86/stack-frame-layout-remarks-32.ll @@ -1,36 +1,16 @@ ; Test remark output for stack-frame-layout -; ensure basic output works -; RUN: llc -mcpu=corei7 -O1 -pass-remarks-analysis=stack-frame-layout < %s 2>&1 >/dev/null | FileCheck %s - -; check additional slots are displayed when stack is not optimized -; RUN: llc -mcpu=corei7 -O0 -pass-remarks-analysis=stack-frame-layout < %s 2>&1 >/dev/null | FileCheck %s --check-prefix=NO_COLORING - ; check more complex cases ; RUN: llc %s -pass-remarks-analysis=stack-frame-layout -o /dev/null --march=x86 -mcpu=i386 2>&1 | FileCheck %s --check-prefix=BOTH --check-prefix=DEBUG ; check output without debug info ; RUN: opt %s -passes=strip -S | llc -pass-remarks-analysis=stack-frame-layout -o /dev/null --march=x86 -mcpu=i386 2>&1 | FileCheck %s --check-prefix=BOTH --check-prefix=STRIPPED -target triple = "x86_64-unknown-linux-gnu" +target triple = "i386-unknown-linux-gnu" @.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 declare i32 @printf(ptr, ...) -; CHECK: Function: stackSizeWarning -; CHECK: Offset: [SP-88], Type: Variable, Align: 16, Size: 80 -; CHECK: buffer @ frame-diags.c:30 -; NO_COLORING: Offset: [SP-168], Type: Variable, Align: 16, Size: 80 -; CHECK: buffer2 @ frame-diags.c:33 -define void @stackSizeWarning() { -entry: - %buffer = alloca [80 x i8], align 16 - %buffer2 = alloca [80 x i8], align 16 - call void @llvm.dbg.declare(metadata ptr %buffer, metadata !25, metadata !DIExpression()), !dbg !39 - call void @llvm.dbg.declare(metadata ptr %buffer2, metadata !31, metadata !DIExpression()), !dbg !40 - ret void -} - ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 @@ -208,7 +188,7 @@ } ; uselistorder directives -uselistorder ptr @llvm.dbg.declare, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 18 } +uselistorder ptr @llvm.dbg.declare, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 16 } attributes #0 = { nocallback nofree nosync nounwind readnone speculatable willreturn } attributes #1 = { "frame-pointer"="all" } @@ -222,19 +202,19 @@ !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !4, splitDebugInlining: false, nameTableKind: None) !3 = !DIFile(filename: "dot.c", directory: "") !4 = !{!5, !6, !10, !13} -!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Array", file: !3, line: 3, size: 128, elements: !8) +!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 32) +!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32) +!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Array", file: !3, line: 3, size: 64, elements: !8) !8 = !{!9, !12} -!9 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !7, file: !3, line: 4, baseType: !10, size: 64) -!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64) +!9 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !7, file: !3, line: 4, baseType: !10, size: 32) +!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 32) !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!12 = !DIDerivedType(tag: DW_TAG_member, name: "size", scope: !7, file: !3, line: 5, baseType: !11, size: 32, offset: 64) -!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64) -!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Result", file: !3, line: 8, size: 128, elements: !15) +!12 = !DIDerivedType(tag: DW_TAG_member, name: "size", scope: !7, file: !3, line: 5, baseType: !11, size: 32, offset: 32) +!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 32) +!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Result", file: !3, line: 8, size: 64, elements: !15) !15 = !{!16, !17} -!16 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !14, file: !3, line: 9, baseType: !6, size: 64) -!17 = !DIDerivedType(tag: DW_TAG_member, name: "sum", scope: !14, file: !3, line: 10, baseType: !11, size: 32, offset: 64) +!16 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !14, file: !3, line: 9, baseType: !6, size: 32) +!17 = !DIDerivedType(tag: DW_TAG_member, name: "sum", scope: !14, file: !3, line: 10, baseType: !11, size: 32, offset: 32) !18 = !{i32 7, !"Dwarf Version", i32 5} !19 = !{i32 2, !"Debug Info Version", i32 3} !20 = !{i32 1, !"wchar_size", i32 4} Index: llvm/test/CodeGen/X86/stack-frame-layout-remarks-64.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/X86/stack-frame-layout-remarks-64.ll @@ -0,0 +1,76 @@ +; Test remark output for stack-frame-layout + +; ensure basic output works +; RUN: llc -mcpu=corei7 -O1 -pass-remarks-analysis=stack-frame-layout < %s 2>&1 >/dev/null | FileCheck %s + +; check additional slots are displayed when stack is not optimized +; RUN: llc -mcpu=corei7 -O0 -pass-remarks-analysis=stack-frame-layout < %s 2>&1 >/dev/null | FileCheck %s --check-prefix=NO_COLORING + +target triple = "x86_64-unknown-linux-gnu" + +@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 +declare i32 @printf(ptr, ...) + +; CHECK: Function: stackSizeWarning +; CHECK: Offset: [SP-88], Type: Variable, Align: 16, Size: 80 +; CHECK: buffer @ frame-diags.c:30 +; NO_COLORING: Offset: [SP-168], Type: Variable, Align: 16, Size: 80 +; CHECK: buffer2 @ frame-diags.c:33 +define void @stackSizeWarning() { +entry: + %buffer = alloca [80 x i8], align 16 + %buffer2 = alloca [80 x i8], align 16 + call void @llvm.dbg.declare(metadata ptr %buffer, metadata !25, metadata !DIExpression()), !dbg !39 + call void @llvm.dbg.declare(metadata ptr %buffer2, metadata !31, metadata !DIExpression()), !dbg !40 + ret void +} + +; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) +declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 + +attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } + +!llvm.dbg.cu = !{!0, !2} +!llvm.module.flags = !{!18, !19, !20, !21, !22, !23, !24} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) +!1 = !DIFile(filename: "frame-diags.c", directory: "") +!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !4, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "dot.c", directory: "") +!4 = !{!5, !6, !10, !13} +!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) +!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Array", file: !3, line: 3, size: 128, elements: !8) +!8 = !{!9, !12} +!9 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !7, file: !3, line: 4, baseType: !10, size: 64) +!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64) +!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!12 = !DIDerivedType(tag: DW_TAG_member, name: "size", scope: !7, file: !3, line: 5, baseType: !11, size: 32, offset: 64) +!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64) +!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Result", file: !3, line: 8, size: 128, elements: !15) +!15 = !{!16, !17} +!16 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !14, file: !3, line: 9, baseType: !6, size: 64) +!17 = !DIDerivedType(tag: DW_TAG_member, name: "sum", scope: !14, file: !3, line: 10, baseType: !11, size: 32, offset: 64) +!18 = !{i32 7, !"Dwarf Version", i32 5} +!19 = !{i32 2, !"Debug Info Version", i32 3} +!20 = !{i32 1, !"wchar_size", i32 4} +!21 = !{i32 8, !"PIC Level", i32 2} +!22 = !{i32 7, !"PIE Level", i32 2} +!23 = !{i32 7, !"uwtable", i32 2} +!24 = !{i32 7, !"frame-pointer", i32 2} +!25 = !DILocalVariable(name: "buffer", scope: !26, file: !1, line: 30, type: !32) +!26 = distinct !DILexicalBlock(scope: !27, file: !1, line: 29, column: 3) +!27 = distinct !DISubprogram(name: "stackSizeWarning", scope: !1, file: !1, line: 28, type: !28, scopeLine: 28, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !30) +!28 = !DISubroutineType(types: !29) +!29 = !{null} +!30 = !{!25, !31, !36, !37} +!31 = !DILocalVariable(name: "buffer2", scope: !27, file: !1, line: 33, type: !32) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 640, elements: !34) +!33 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!34 = !{!35} +!35 = !DISubrange(count: 80) +!36 = !DILocalVariable(name: "a", scope: !27, file: !1, line: 34, type: !11) +!37 = !DILocalVariable(name: "b", scope: !27, file: !1, line: 35, type: !38) +!38 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!39 = !DILocation(line: 30, column: 10, scope: !26) +!40 = !DILocation(line: 33, column: 8, scope: !27) Index: llvm/test/DebugInfo/Generic/discriminated-union.ll =================================================================== --- llvm/test/DebugInfo/Generic/discriminated-union.ll +++ llvm/test/DebugInfo/Generic/discriminated-union.ll @@ -25,14 +25,14 @@ ; CHECK: DW_AT_alignment ; CHECK: DW_AT_data_member_location [DW_FORM_data1] (0x00) -%F = type { [0 x i8], ptr, [8 x i8] } +%F = type { [0 x i8], i64, [8 x i8] } %"F::Nope" = type {} define internal void @_ZN2e34main17h934ff72f9a38d4bbE() unnamed_addr #0 !dbg !5 { start: %qq = alloca %F, align 8 call void @llvm.dbg.declare(metadata ptr %qq, metadata !10, metadata !28), !dbg !29 - store ptr null, ptr %qq, !dbg !29 + store i64 0, ptr %qq, !dbg !29 ret void, !dbg !30 } Index: llvm/test/DebugInfo/Generic/dwarf-public-names.ll =================================================================== --- llvm/test/DebugInfo/Generic/dwarf-public-names.ll +++ /dev/null @@ -1,137 +0,0 @@ -; RUN: %llc_dwarf -debugger-tune=gdb -filetype=obj -o %t.o < %s -; RUN: llvm-dwarfdump -debug-pubnames %t.o | FileCheck %s -; ModuleID = 'dwarf-public-names.cpp' -; -; Generated from: -; -; struct C { -; void member_function(); -; static int static_member_function(); -; static int static_member_variable; -; }; -; -; int C::static_member_variable = 0; -; -; void C::member_function() { -; static_member_variable = 0; -; } -; -; int C::static_member_function() { -; return static_member_variable; -; } -; -; C global_variable; -; -; int global_function() { -; return -1; -; } -; -; namespace ns { -; void global_namespace_function() { -; global_variable.member_function(); -; } -; int global_namespace_variable = 1; -; } - -; Skip the output to the header of the pubnames section. -; CHECK: debug_pubnames -; CHECK: version = 0x0002 - -; Check for each name in the output. -; CHECK-DAG: "ns" -; CHECK-DAG: "C::static_member_function" -; CHECK-DAG: "global_variable" -; CHECK-DAG: "ns::global_namespace_variable" -; CHECK-DAG: "ns::global_namespace_function" -; CHECK-DAG: "global_function" -; CHECK-DAG: "C::static_member_variable" -; CHECK-DAG: "C::member_function" - -source_filename = "test/DebugInfo/Generic/dwarf-public-names.ll" - -%struct.C = type { i8 } - -@_ZN1C22static_member_variableE = global i32 0, align 4, !dbg !0 -@global_variable = global %struct.C zeroinitializer, align 1, !dbg !15 -@_ZN2ns25global_namespace_variableE = global i32 1, align 4, !dbg !17 - -; Function Attrs: nounwind uwtable -define void @_ZN1C15member_functionEv(ptr %this) #0 align 2 !dbg !23 { -entry: - %this.addr = alloca ptr, align 8 - store ptr %this, ptr %this.addr, align 8 - call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !24, metadata !26), !dbg !27 - %this1 = load ptr, ptr %this.addr - store i32 0, ptr @_ZN1C22static_member_variableE, align 4, !dbg !28 - ret void, !dbg !29 -} - -; Function Attrs: nounwind readnone -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -; Function Attrs: nounwind uwtable -define i32 @_ZN1C22static_member_functionEv() #0 align 2 !dbg !30 { -entry: - %0 = load i32, ptr @_ZN1C22static_member_variableE, align 4, !dbg !31 - ret i32 %0, !dbg !31 -} - -; Function Attrs: nounwind uwtable -define i32 @_Z15global_functionv() #0 !dbg !32 { -entry: - ret i32 -1, !dbg !33 -} - -; Function Attrs: nounwind uwtable -define void @_ZN2ns25global_namespace_functionEv() #0 !dbg !34 { -entry: - call void @_ZN1C15member_functionEv(ptr @global_variable), !dbg !37 - ret void, !dbg !38 -} - -attributes #0 = { nounwind uwtable } -attributes #1 = { nounwind readnone } - -!llvm.dbg.cu = !{!20} -!llvm.module.flags = !{!22} - -!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = !DIGlobalVariable(name: "static_member_variable", linkageName: "_ZN1C22static_member_variableE", scope: !2, file: !3, line: 7, type: !6, isLocal: false, isDefinition: true, declaration: !5) -!2 = !DICompositeType(tag: DW_TAG_structure_type, name: "C", file: !3, line: 1, size: 8, align: 8, elements: !4) -!3 = !DIFile(filename: "dwarf-public-names.cpp", directory: "/usr2/kparzysz/s.hex/t") -!4 = !{!5, !7, !12} -!5 = !DIDerivedType(tag: DW_TAG_member, name: "static_member_variable", scope: !2, file: !3, line: 4, baseType: !6, flags: DIFlagStaticMember) -!6 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) -!7 = !DISubprogram(name: "member_function", linkageName: "_ZN1C15member_functionEv", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: false, scopeLine: 2, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, retainedNodes: !11) -!8 = !DISubroutineType(types: !9) -!9 = !{null, !10} -!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !2, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer) -!11 = !{} -!12 = !DISubprogram(name: "static_member_function", linkageName: "_ZN1C22static_member_functionEv", scope: !2, file: !3, line: 3, type: !13, isLocal: false, isDefinition: false, scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, retainedNodes: !11) -!13 = !DISubroutineType(types: !14) -!14 = !{!6} -!15 = !DIGlobalVariableExpression(var: !16, expr: !DIExpression()) -!16 = !DIGlobalVariable(name: "global_variable", scope: null, file: !3, line: 17, type: !2, isLocal: false, isDefinition: true) ; previously: invalid DW_TAG_base_type -!17 = !DIGlobalVariableExpression(var: !18, expr: !DIExpression()) -!18 = !DIGlobalVariable(name: "global_namespace_variable", linkageName: "_ZN2ns25global_namespace_variableE", scope: !19, file: !3, line: 27, type: !6, isLocal: false, isDefinition: true) -!19 = !DINamespace(name: "ns", scope: null) -!20 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 3.3", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !11, retainedTypes: !11, globals: !21, imports: !11) ; previously: invalid DW_TAG_base_type -!21 = !{!0, !15, !17} -!22 = !{i32 1, !"Debug Info Version", i32 3} -!23 = distinct !DISubprogram(name: "member_function", linkageName: "_ZN1C15member_functionEv", scope: null, file: !3, line: 9, type: !8, isLocal: false, isDefinition: true, scopeLine: 9, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !20, declaration: !7, retainedNodes: !11) -!24 = !DILocalVariable(name: "this", arg: 1, scope: !23, file: !3, line: 9, type: !25, flags: DIFlagArtificial | DIFlagObjectPointer) -!25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !2, size: 64, align: 64) -!26 = !DIExpression() -!27 = !DILocation(line: 9, scope: !23) -!28 = !DILocation(line: 10, scope: !23) -!29 = !DILocation(line: 11, scope: !23) -!30 = distinct !DISubprogram(name: "static_member_function", linkageName: "_ZN1C22static_member_functionEv", scope: null, file: !3, line: 13, type: !13, isLocal: false, isDefinition: true, scopeLine: 13, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !20, declaration: !12, retainedNodes: !11) -!31 = !DILocation(line: 14, scope: !30) -!32 = distinct !DISubprogram(name: "global_function", linkageName: "_Z15global_functionv", scope: !3, file: !3, line: 19, type: !13, isLocal: false, isDefinition: true, scopeLine: 19, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !20, retainedNodes: !11) -!33 = !DILocation(line: 20, scope: !32) -!34 = distinct !DISubprogram(name: "global_namespace_function", linkageName: "_ZN2ns25global_namespace_functionEv", scope: !19, file: !3, line: 24, type: !35, isLocal: false, isDefinition: true, scopeLine: 24, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !20, retainedNodes: !11) -!35 = !DISubroutineType(types: !36) -!36 = !{null} -!37 = !DILocation(line: 25, scope: !34) -!38 = !DILocation(line: 26, scope: !34) - Index: llvm/test/DebugInfo/Generic/univariant-discriminated-union.ll =================================================================== --- llvm/test/DebugInfo/Generic/univariant-discriminated-union.ll +++ llvm/test/DebugInfo/Generic/univariant-discriminated-union.ll @@ -12,14 +12,14 @@ ; CHECK: DW_AT_alignment ; CHECK: DW_AT_data_member_location [DW_FORM_data1] (0x00) -%F = type { [0 x i8], ptr, [8 x i8] } +%F = type { [0 x i8], i64, [8 x i8] } %"F::Nope" = type {} define internal void @_ZN2e34main17h934ff72f9a38d4bbE() unnamed_addr #0 !dbg !5 { start: %qq = alloca %F, align 8 call void @llvm.dbg.declare(metadata ptr %qq, metadata !10, metadata !28), !dbg !29 - store ptr null, ptr %qq, !dbg !29 + store i64 0, ptr %qq, !dbg !29 ret void, !dbg !30 } Index: llvm/test/DebugInfo/X86/PR20038.ll =================================================================== --- llvm/test/DebugInfo/X86/PR20038.ll +++ llvm/test/DebugInfo/X86/PR20038.ll @@ -1,7 +1,4 @@ -; For some reason, the output when targetting sparc is not quite as expected. -; XFAIL: target=sparc{{.*}} - -; RUN: %llc_dwarf -O0 -filetype=obj -dwarf-linkage-names=All < %s | llvm-dwarfdump -debug-info - | FileCheck %s --implicit-check-not=DW_TAG +; RUN: %llc_dwarf -mtriple=x86_64-unknown-linux-gnu -O0 -filetype=obj -dwarf-linkage-names=All < %s | llvm-dwarfdump -debug-info - | FileCheck %s --implicit-check-not=DW_TAG ; IR generated from clang -O0 with: ; struct C { Index: llvm/test/DebugInfo/X86/fi-piece.ll =================================================================== --- llvm/test/DebugInfo/X86/fi-piece.ll +++ llvm/test/DebugInfo/X86/fi-piece.ll @@ -5,7 +5,7 @@ ; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_abstract_origin ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_fbreg -4, DW_OP_piece 0x2, DW_OP_fbreg -8, DW_OP_piece 0x2) +; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_fbreg -8, DW_OP_piece 0x2, DW_OP_fbreg -12, DW_OP_piece 0x2) ; CHECK-NEXT: DW_AT_abstract_origin {{.*}}"a" ; Inlined variable, not to be merged. ; CHECK-NOT: DW_TAG @@ -25,10 +25,11 @@ entry: %a = alloca i16, align 4 %b = alloca i16, align 4 + %c = alloca { i16, i16 }, align 4 call void @llvm.dbg.declare(metadata ptr %a, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 16)), !dbg !14 store i16 1, ptr %a, align 4, !dbg !14 call void @llvm.dbg.declare(metadata ptr %b, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 16, 16)), !dbg !16 - call void @llvm.dbg.declare(metadata ptr %a, metadata !11, metadata !13), !dbg !17 + call void @llvm.dbg.declare(metadata ptr %c, metadata !11, metadata !13), !dbg !17 store i16 2, ptr %b, align 4, !dbg !17 ret void } Index: llvm/test/DebugInfo/X86/member-order.ll =================================================================== --- llvm/test/DebugInfo/X86/member-order.ll +++ llvm/test/DebugInfo/X86/member-order.ll @@ -1,4 +1,4 @@ -; RUN: %llc_dwarf -filetype=obj -O0 < %s | llvm-dwarfdump -debug-info - | FileCheck %s +; RUN: %llc_dwarf -mtriple=x86_64-unknown-linux -filetype=obj -O0 < %s | llvm-dwarfdump -debug-info - | FileCheck %s ; generated by clang from: ; struct foo { Index: llvm/test/DebugInfo/X86/tu-composite.ll =================================================================== --- llvm/test/DebugInfo/X86/tu-composite.ll +++ llvm/test/DebugInfo/X86/tu-composite.ll @@ -1,4 +1,4 @@ -; RUN: %llc_dwarf -filetype=obj -O0 < %s > %t +; RUN: %llc_dwarf -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s > %t ; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s ; CHECK: [[TYPE:.*]]: DW_TAG_structure_type ; Make sure we correctly handle containing type of a struct being a type identifier. Index: llvm/test/DebugInfo/invalid-sizes.ll =================================================================== --- /dev/null +++ llvm/test/DebugInfo/invalid-sizes.ll @@ -0,0 +1,80 @@ +; RUN: llvm-as -disable-output < %s 2>&1 | FileCheck %s + +; CHECK: llvm.dbg.declare has larger fragment size than alloca size +; CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %slice.dbg.spill, metadata !23, metadata !DIExpression()) +; CHECK: llvm.dbg.declare has larger fragment size than alloca size +; CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %slice.dbg.spill1, metadata !23, metadata !DIExpression()) + +%"EndianSlice<'_>" = type { { ptr, i64 }, i32, [1 x i32] } + +; example::test +; Function Attrs: nonlazybind uwtable +define void @_ZN7example4test17h64a501af0fe536ddE(ptr align 1 %s.0, i64 %s.1) unnamed_addr #0 !dbg !7 { +start: + %slice.dbg.spill1 = alloca i32, align 4 + %slice.dbg.spill = alloca { ptr, i64 }, align 8 + %s.dbg.spill = alloca { ptr, i64 }, align 8 + %_2 = alloca %"EndianSlice<'_>", align 8 + %0 = getelementptr inbounds { ptr, i64 }, ptr %s.dbg.spill, i32 0, i32 0 + store ptr %s.0, ptr %0, align 8 + %1 = getelementptr inbounds { ptr, i64 }, ptr %s.dbg.spill, i32 0, i32 1 + store i64 %s.1, ptr %1, align 8 + call void @llvm.dbg.declare(metadata ptr %s.dbg.spill, metadata !22, metadata !DIExpression()), !dbg !33 + %2 = getelementptr inbounds { ptr, i64 }, ptr %slice.dbg.spill, i32 0, i32 0, !dbg !34 + store ptr %s.0, ptr %2, align 8, !dbg !34 + %3 = getelementptr inbounds { ptr, i64 }, ptr %slice.dbg.spill, i32 0, i32 1, !dbg !34 + store i64 %s.1, ptr %3, align 8, !dbg !34 + call void @llvm.dbg.declare(metadata ptr %slice.dbg.spill, metadata !23, metadata !DIExpression()), !dbg !35 + store i32 1, ptr %slice.dbg.spill1, align 4, !dbg !34 + call void @llvm.dbg.declare(metadata ptr %slice.dbg.spill1, metadata !23, metadata !DIExpression()), !dbg !35 + ret void, !dbg !36 +} + +; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +attributes #0 = { nonlazybind uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" } +attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} +!llvm.dbg.cu = !{!5} + +!0 = !{i32 8, !"PIC Level", i32 2} +!1 = !{i32 2, !"RtLibUseGOT", i32 1} +!2 = !{i32 2, !"Dwarf Version", i32 4} +!3 = !{i32 2, !"Debug Info Version", i32 3} +!4 = !{!"rustc version 1.74.0-nightly (5c6a7e71c 2023-08-20)"} +!5 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !6, producer: "clang LLVM (rustc version 1.74.0-nightly (5c6a7e71c 2023-08-20))", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +!6 = !DIFile(filename: "/app/example.rs/@/example.a6c375ed18e8f6d3-cgu.0", directory: "/app") +!7 = distinct !DISubprogram(name: "test", linkageName: "_ZN7example4test17h64a501af0fe536ddE", scope: !9, file: !8, line: 9, type: !10, scopeLine: 9, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !5, templateParams: !20, retainedNodes: !21) +!8 = !DIFile(filename: "example.rs", directory: "/app", checksumkind: CSK_MD5, checksum: "bd53c9e80c244adbeae5aa0d57de599d") +!9 = !DINamespace(name: "example", scope: null) +!10 = !DISubroutineType(types: !11) +!11 = !{null, !12} +!12 = !DICompositeType(tag: DW_TAG_structure_type, name: "&[u8]", file: !13, size: 128, align: 64, elements: !14, templateParams: !20, identifier: "4f7d759e2003ffb713a77bd933fd0146") +!13 = !DIFile(filename: "", directory: "") +!14 = !{!15, !18} +!15 = !DIDerivedType(tag: DW_TAG_member, name: "data_ptr", scope: !12, file: !13, baseType: !16, size: 64, align: 64) +!16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !17, size: 64, align: 64, dwarfAddressSpace: 0) +!17 = !DIBasicType(name: "u8", size: 8, encoding: DW_ATE_unsigned) +!18 = !DIDerivedType(tag: DW_TAG_member, name: "length", scope: !12, file: !13, baseType: !19, size: 64, align: 64, offset: 64) +!19 = !DIBasicType(name: "usize", size: 64, encoding: DW_ATE_unsigned) +!20 = !{} +!21 = !{!22, !23} +!22 = !DILocalVariable(name: "s", arg: 1, scope: !7, file: !8, line: 9, type: !12) +!23 = !DILocalVariable(name: "slice", scope: !24, file: !8, line: 10, type: !25, align: 8) +!24 = distinct !DILexicalBlock(scope: !7, file: !8, line: 10, column: 5) +!25 = !DICompositeType(tag: DW_TAG_structure_type, name: "EndianSlice", scope: !9, file: !13, size: 192, align: 64, elements: !26, templateParams: !20, identifier: "f1b6e593370159e9df4228aa26ace4b5") +!26 = !{!27, !28} +!27 = !DIDerivedType(tag: DW_TAG_member, name: "slice", scope: !25, file: !13, baseType: !12, size: 128, align: 64) +!28 = !DIDerivedType(tag: DW_TAG_member, name: "endian", scope: !25, file: !13, baseType: !29, size: 32, align: 32, offset: 128) +!29 = !DICompositeType(tag: DW_TAG_structure_type, name: "Endian", scope: !9, file: !13, size: 32, align: 32, elements: !30, templateParams: !20, identifier: "a76092aada82685a5b963f3da7ae1bd9") +!30 = !{!31} +!31 = !DIDerivedType(tag: DW_TAG_member, name: "__0", scope: !29, file: !13, baseType: !32, size: 32, align: 32) +!32 = !DIBasicType(name: "i32", size: 32, encoding: DW_ATE_signed) +!33 = !DILocation(line: 9, column: 13, scope: !7) +!34 = !DILocation(line: 10, column: 17, scope: !7) +!35 = !DILocation(line: 10, column: 9, scope: !24) +!36 = !DILocation(line: 11, column: 2, scope: !37) +!37 = !DILexicalBlockFile(scope: !7, file: !8, discriminator: 0) Index: llvm/test/Linker/type-unique-odr-a.ll =================================================================== --- llvm/test/Linker/type-unique-odr-a.ll +++ llvm/test/Linker/type-unique-odr-a.ll @@ -1,4 +1,4 @@ -; REQUIRES: object-emission +; REQUIRES: x86-registered-target ; ; RUN: llvm-link %s %p/type-unique-odr-b.ll -S -o - \ ; RUN: | %llc_dwarf -dwarf-linkage-names=All -filetype=obj -O0 \ @@ -56,6 +56,8 @@ ; ModuleID = 'type-unique-odr-a.cpp' +target triple = "x86_64-unknown-linux-gnu" + %class.A = type { i32 } ; Function Attrs: nounwind Index: llvm/test/Linker/type-unique-odr-b.ll =================================================================== --- llvm/test/Linker/type-unique-odr-b.ll +++ llvm/test/Linker/type-unique-odr-b.ll @@ -19,6 +19,8 @@ ; ModuleID = 'type-unique-odr-b.cpp' +target triple = "x86_64-unknown-linux-gnu" + %class.A = type { i32 } ; Function Attrs: nounwind Index: llvm/test/Linker/type-unique-simple2-a.ll =================================================================== --- llvm/test/Linker/type-unique-simple2-a.ll +++ llvm/test/Linker/type-unique-simple2-a.ll @@ -1,4 +1,4 @@ -; REQUIRES: object-emission +; REQUIRES: x86-registered-target ; ; RUN: llvm-link %s %p/type-unique-simple2-b.ll -S -o - | %llc_dwarf -filetype=obj -O0 | llvm-dwarfdump -v -debug-info - | FileCheck %s ; @@ -26,6 +26,8 @@ ; ModuleID = 'a.cpp' +target triple = "x86_64-unknown-linux-gnu" + %class.A = type { ptr } @_ZTV1A = external unnamed_addr constant [4 x ptr] Index: llvm/test/Linker/type-unique-simple2-b.ll =================================================================== --- llvm/test/Linker/type-unique-simple2-b.ll +++ llvm/test/Linker/type-unique-simple2-b.ll @@ -10,6 +10,8 @@ ; target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" ; target triple = "x86_64-apple-macosx10.9.0" +target triple = "x86_64-unknown-linux-gnu" + %class.A = type { ptr } @_ZTV1A = unnamed_addr constant [4 x ptr] [ptr null, ptr @_ZTI1A, ptr @_ZN1A6setFooEv, ptr @_ZN1A6getFooEv] Index: llvm/test/Transforms/InstCombine/dbg-scalable-store-fixed-frag.ll =================================================================== --- llvm/test/Transforms/InstCombine/dbg-scalable-store-fixed-frag.ll +++ llvm/test/Transforms/InstCombine/dbg-scalable-store-fixed-frag.ll @@ -4,14 +4,14 @@ define i32 @foo( %x) { ; CHECK-LABEL: @foo( ; CHECK-NEXT: entry: -; CHECK-NEXT: [[ARR:%.*]] = alloca i32, align 8 -; CHECK-NEXT: call void @llvm.dbg.value(metadata undef, metadata [[META8:![0-9]+]], metadata !DIExpression()), !dbg [[DBG14:![0-9]+]] +; CHECK-NEXT: [[ARR:%.*]] = alloca [4 x i32], align 8 +; CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr [[ARR]], metadata [[META8:![0-9]+]], metadata !DIExpression()), !dbg [[DBG14:![0-9]+]] ; CHECK-NEXT: store [[X:%.*]], ptr [[ARR]], align 8 ; CHECK-NEXT: [[RES:%.*]] = load i32, ptr [[ARR]], align 8 ; CHECK-NEXT: ret i32 [[RES]] ; entry: - %arr = alloca i32, align 4 + %arr = alloca [4 x i32], align 4 call void @llvm.dbg.declare(metadata ptr %arr, metadata !8, metadata !DIExpression()), !dbg !14 store %x, ptr %arr, align 4 %res = load i32, ptr %arr Index: llvm/test/Transforms/InstCombine/dbg-simplify-alloca-size.ll =================================================================== --- llvm/test/Transforms/InstCombine/dbg-simplify-alloca-size.ll +++ llvm/test/Transforms/InstCombine/dbg-simplify-alloca-size.ll @@ -7,13 +7,13 @@ ; CHECK-LABEL: @toplevel( ; CHECK: entry: -; CHECK-NEXT: %pixels1 = alloca [3 x i8], align 1 +; CHECK-NEXT: %pixels1 = alloca [4 x i8], align 1 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %pixels1, metadata ![[MD:[0-9]+]], metadata !DIExpression()), !dbg ![[DBG:[0-9]+]] ; CHECK-NEXT: call void @foo(ptr nonnull %pixels1) ; CHECK-NEXT: ret void define dso_local void @toplevel() { entry: - %pixels = alloca i8, i32 3 + %pixels = alloca i8, i32 4 call void @llvm.dbg.declare(metadata ptr %pixels, metadata !11, metadata !DIExpression()), !dbg !12 call void @foo(ptr %pixels) ret void Index: llvm/test/Transforms/Util/dbg-user-of-aext.ll =================================================================== --- llvm/test/Transforms/Util/dbg-user-of-aext.ll +++ llvm/test/Transforms/Util/dbg-user-of-aext.ll @@ -3,6 +3,8 @@ ; opposed to the operand of a [s|z]ext). ; RUN: opt -S -passes='sroa' %s | FileCheck %s +target datalayout = "i64:64" + ; Built from: ; struct foo { bool b; long i; }; ; void f(bool b, bool expr, foo g) { @@ -12,15 +14,15 @@ ; Expect two fragments: ; * first starting at bit 0, 8 bits (for the bool) -; * second starting at bit 32, 32 bits (for the long) -; (this happens to create/demonstrate a gap from bits [7, 32)) +; * second starting at bit 64, 64 bits (for the long) +; (this happens to create/demonstrate a gap from bits [7, 64)) ; But also check that a complex expression is not used for a lone bool ; parameter. It can reference the register it's in directly without masking off ; high bits or anything ; CHECK: call void @llvm.dbg.value(metadata i8 %g.coerce0, metadata ![[VAR_STRUCT:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 8)) -; CHECK: call void @llvm.dbg.value(metadata i64 %g.coerce1, metadata ![[VAR_STRUCT]], metadata !DIExpression(DW_OP_LLVM_fragment, 32, 64)) +; CHECK: call void @llvm.dbg.value(metadata i64 %g.coerce1, metadata ![[VAR_STRUCT]], metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64)) ; CHECK: call void @llvm.dbg.value(metadata i8 %frombool, metadata ![[VAR_BOOL:[0-9]+]], metadata !DIExpression()) ; CHECK: call void @llvm.dbg.value(metadata i8 %frombool1, metadata ![[VAR_FRAG:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 4))