[llvm] Split DWARF v2 tests to exclude 64-bit AIX targets (PR #189077)
Lei Huang via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 2 09:01:27 PDT 2026
https://github.com/lei137 updated https://github.com/llvm/llvm-project/pull/189077
>From bfdefe0b22cdf40343b4c0d31708a947bdcdd491 Mon Sep 17 00:00:00 2001
From: Lei Huang <lei at ca.ibm.com>
Date: Fri, 27 Mar 2026 12:13:35 -0400
Subject: [PATCH 1/3] Split DWARF v2 tests to exclude 64-bit AIX targets
64-bit AIX requires DWARF64 format, which was only introduced in DWARF
v3. DWARF v2 only supports 32-bit DWARF format, making it incompatible
with 64-bit AIX (the compiler throws a fatal error). These changes split
DWARF v2 tests into separate files that exclude 64-bit AIX targets while
still running on 32-bit AIX and other 64-bit platforms where DWARF v2 is
supported.
---
.../Generic/debug-info-enum-32bit.ll | 210 ++++++++++++++++++
.../test/DebugInfo/Generic/debug-info-enum.ll | 6 +-
.../incorrect-variable-debugloc1-32bit.ll | 80 +++++++
.../Generic/incorrect-variable-debugloc1.ll | 3 +-
llvm/test/DebugInfo/Generic/restrict-32bit.ll | 51 +++++
llvm/test/DebugInfo/Generic/restrict.ll | 3 +-
6 files changed, 347 insertions(+), 6 deletions(-)
create mode 100644 llvm/test/DebugInfo/Generic/debug-info-enum-32bit.ll
create mode 100644 llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1-32bit.ll
create mode 100644 llvm/test/DebugInfo/Generic/restrict-32bit.ll
diff --git a/llvm/test/DebugInfo/Generic/debug-info-enum-32bit.ll b/llvm/test/DebugInfo/Generic/debug-info-enum-32bit.ll
new file mode 100644
index 0000000000000..108e7b3c35f49
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/debug-info-enum-32bit.ll
@@ -0,0 +1,210 @@
+; Test enumeration representation in DWARF debug info for 32-bit targets:
+; * test value representation for each possible underlying integer type
+; * test the integer type is as expected
+; * test the DW_AT_enum_class attribute is present (resp. absent) as expected.
+; * test that DW_AT_type is present for v3 and greater, and v2 when strict DWARF
+; is not enabled.
+
+; This file contains the dwarf-version=2 tests extracted from debug-info-enum.ll
+; DWARF v2 is incompatible with 64-bit XCOFF/AIX (requires DWARF64 format which needs DWARF v3+)
+
+; UNSUPPORTED: target=powerpc64{{.*}}-aix{{.*}}
+
+; RUN: llc -debugger-tune=gdb -dwarf-version=2 -filetype=obj -o %t.o < %s
+; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s --check-prefixes=CHECK,CHECK-TYPE
+; RUN: llc -debugger-tune=gdb -dwarf-version=2 -strict-dwarf=true -filetype=obj -o %t.o < %s
+; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s --check-prefixes=CHECK,CHECK-DW2-STRICT
+
+ at x0 = global i8 0, align 1, !dbg !0
+ at x1 = global i8 0, align 1, !dbg !46
+ at x2 = global i16 0, align 2, !dbg !48
+ at x3 = global i16 0, align 2, !dbg !50
+ at x4 = global i32 0, align 4, !dbg !52
+ at x5 = global i32 0, align 4, !dbg !54
+ at x6 = global i64 0, align 8, !dbg !56
+ at x7 = global i64 0, align 8, !dbg !58
+ at x8 = global i32 0, align 4, !dbg !60
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!62}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "x0", scope: !2, file: !3, line: 5, type: !5, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 7.0.0 (/data/src/llvm/tools/clang 0c08d9830124a75675348b4eeb47256f3da6693d) (/data/src/llvm cf29510f52faa77b98510cd53276f564d1f4f41f)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !45)
+!3 = !DIFile(filename: "/data/src/llvm-dev/tools/clang/test/CodeGen/debug-info-enum.cpp", directory: "/work/build/clang-dev")
+!4 = !{!5, !10, !14, !19, !23, !28, !32, !37, !41}
+
+; Test enumeration with a fixed "signed char" underlying type.
+!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E0", file: !3, line: 2, baseType: !6, size: 8, flags: DIFlagEnumClass, elements: !7, identifier: "_ZTS2E0")
+!6 = !DIBasicType(name: "signed char", size: 8, encoding: DW_ATE_signed_char)
+!7 = !{!8, !9}
+!8 = !DIEnumerator(name: "A0", value: -128)
+!9 = !DIEnumerator(name: "B0", value: 127)
+; CHECK: DW_TAG_enumeration_type
+; CHECK-DW2-STRICT-NOT: DW_AT_type
+; CHECK-TYPE: DW_AT_type{{.*}}"signed char"
+; CHECK-NOT: DW_AT_enum_class
+; CHECK: DW_AT_name ("E0")
+; CHECK: DW_TAG_enumerator
+; CHECK: DW_AT_name ("A0")
+; CHECK-NEXT: DW_AT_const_value (-128)
+; CHECK: DW_TAG_enumerator
+; CHECK: DW_AT_name ("B0")
+; CHECK-NEXT: DW_AT_const_value (127)
+
+; Test enumeration with a fixed "unsigned char" underlying type.
+!10 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E1", file: !3, line: 12, baseType: !11, size: 8, flags: DIFlagEnumClass, elements: !12, identifier: "_ZTS2E1")
+!11 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)
+!12 = !{!13}
+!13 = !DIEnumerator(name: "A1", value: 255, isUnsigned: true)
+; CHECK: DW_TAG_enumeration_type
+; CHECK-DW2-STRICT-NOT: DW_AT_type
+; CHECK-TYPE: DW_AT_type{{.*}}"unsigned char"
+; CHECK-NOT: DW_AT_enum_class
+; CHECK: DW_AT_name ("E1")
+; CHECK: DW_TAG_enumerator
+; CHECK: DW_AT_name ("A1")
+; CHECK-NEXT: DW_AT_const_value (255)
+
+; Test enumeration with a fixed "short" underlying type.
+!14 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E2", file: !3, line: 18, baseType: !15, size: 16, flags: DIFlagEnumClass, elements: !16, identifier: "_ZTS2E2")
+!15 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
+!16 = !{!17, !18}
+!17 = !DIEnumerator(name: "A2", value: -32768)
+!18 = !DIEnumerator(name: "B2", value: 32767)
+; CHECK: DW_TAG_enumeration_type
+; CHECK-DW2-STRICT-NOT: DW_AT_type
+; CHECK-TYPE: DW_AT_type{{.*}} "short"
+; CHECK-NOT: DW_AT_enum_class
+; CHECK: DW_AT_name ("E2")
+; CHECK: DW_TAG_enumerator
+; CHECK: DW_AT_name ("A2")
+; CHECK-NEXT: DW_AT_const_value (-32768)
+; CHECK: DW_TAG_enumerator
+; CHECK: DW_AT_name ("B2")
+; CHECK-NEXT: DW_AT_const_value (32767)
+
+; Test enumeration with a fixed "unsigned short" underlying type.
+!19 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E3", file: !3, line: 28, baseType: !20, size: 16, flags: DIFlagEnumClass, elements: !21, identifier: "_ZTS2E3")
+!20 = !DIBasicType(name: "unsigned short", size: 16, encoding: DW_ATE_unsigned)
+!21 = !{!22}
+!22 = !DIEnumerator(name: "A3", value: 65535, isUnsigned: true)
+; CHECK: DW_TAG_enumeration_type
+; CHECK-DW2-STRICT-NOT: DW_AT_type
+; CHECK-TYPE DW_AT_type{{.*}}"unsigned short"
+; CHECK-NOT: DW_AT_enum_class
+; CHECK: DW_AT_name ("E3")
+; CHECK: DW_TAG_enumerator
+; CHECK: DW_AT_name ("A3")
+; CHECK-NEXT: DW_AT_const_value (65535)
+
+; Test enumeration with a fixed "int" underlying type.
+!23 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E4", file: !3, line: 34, baseType: !24, size: 32, flags: DIFlagEnumClass, elements: !25, identifier: "_ZTS2E4")
+!24 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!25 = !{!26, !27}
+!26 = !DIEnumerator(name: "A4", value: -2147483648)
+!27 = !DIEnumerator(name: "B4", value: 2147483647)
+; CHECK: DW_TAG_enumeration_type
+; CHECK-DW2-STRICT-NOT: DW_AT_type
+; CHECK-TYPE: DW_AT_type{{.*}}"int"
+; CHECK-NOT: DW_AT_enum_class
+; CHECK: DW_AT_name ("E4")
+; CHECK: DW_TAG_enumerator
+; CHECK: DW_AT_name ("A4")
+; CHECK-NEXT: DW_AT_const_value (-2147483648)
+; CHECK: DW_TAG_enumerator
+; CHECK: DW_AT_name ("B4")
+; CHECK-NEXT: DW_AT_const_value (2147483647)
+
+; Test enumeration with a fixed "unsigend int" underlying type.
+!28 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E5", file: !3, line: 41, baseType: !29, size: 32, flags: DIFlagEnumClass, elements: !30, identifier: "_ZTS2E5")
+!29 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
+!30 = !{!31}
+!31 = !DIEnumerator(name: "A5", value: 4294967295, isUnsigned: true)
+; CHECK: DW_TAG_enumeration_type
+; CHECK-DW2-STRICT-NOT: DW_AT_type
+; CHECK-TYPE: DW_AT_type{{.*}}"unsigned int"
+; CHECK-NOT: DW_AT_enum_class
+; CHECK: DW_AT_name ("E5")
+; CHECK: DW_TAG_enumerator
+; CHECK: DW_AT_name ("A5")
+; CHECK-NEXT: DW_AT_const_value (4294967295)
+
+; Test enumeration with a fixed "long long" underlying type.
+!32 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E6", file: !3, line: 47, baseType: !33, size: 64, flags: DIFlagEnumClass, elements: !34, identifier: "_ZTS2E6")
+!33 = !DIBasicType(name: "long long int", size: 64, encoding: DW_ATE_signed)
+!34 = !{!35, !36}
+!35 = !DIEnumerator(name: "A6", value: -9223372036854775808)
+!36 = !DIEnumerator(name: "B6", value: 9223372036854775807)
+; CHECK: DW_TAG_enumeration_type
+; CHECK-DW2-STRICT-NOT: DW_AT_type
+; CHECK-TYPE: DW_AT_type{{.*}}"long long int"
+; CHECK-NOT: DW_AT_enum_class
+; CHECK: DW_AT_name ("E6")
+; CHECK: DW_TAG_enumerator
+; CHECK: DW_AT_name ("A6")
+; CHECK-NEXT: DW_AT_const_value (-9223372036854775808)
+; CHECK: DW_TAG_enumerator
+; CHECK: DW_AT_name ("B6")
+; CHECK-NEXT: DW_AT_const_value (9223372036854775807)
+
+; Test enumeration with a fixed "unsigned long long" underlying type.
+!37 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E7", file: !3, line: 57, baseType: !38, size: 64, flags: DIFlagEnumClass, elements: !39, identifier: "_ZTS2E7")
+!38 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned)
+!39 = !{!40}
+!40 = !DIEnumerator(name: "A7", value: 18446744073709551615, isUnsigned: true)
+; CHECK: DW_TAG_enumeration_type
+; CHECK-DW2-STRICT-NOT: DW_AT_type
+; CHECK-TYPE: DW_AT_type{{.*}}"long long unsigned int"
+; CHECK-NOT: DW_AT_enum_class
+; CHECK: DW_AT_name ("E7")
+; CHECK: DW_TAG_enumerator
+; CHECK: DW_AT_name ("A7")
+; CHECK-NEXT: DW_AT_const_value (18446744073709551615)
+
+; Test enumeration without a fixed underlying type. The underlying type should
+; still be present (for DWARF >= 3), but the DW_AT_enum_class attribute should
+; be absent.
+!41 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E8", file: !3, line: 63, baseType: !24, size: 32, elements: !42, identifier: "_ZTS2E8")
+!42 = !{!43, !44}
+!43 = !DIEnumerator(name: "A8", value: -128)
+!44 = !DIEnumerator(name: "B8", value: 127)
+; CHECK: DW_TAG_enumeration_type
+; CHECK-DW2-STRICT-NOT: DW_AT_type
+; CHECK-TYPE: DW_AT_type{{.*}}"int"
+; CHECK-NOT: DW_AT_enum_class
+; CHECK: DW_AT_name ("E8")
+
+; Test enumeration without a fixed underlying type, but with the DIFlagEnumClass
+; set. The DW_AT_enum_class attribute should be absent. This behaviour is
+; intented to keep compatibilty with existing DWARF consumers, which may imply
+; the type is present whenever DW_AT_enum_class is set.
+!63 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E9", file: !3, line: 63, size: 32, flags: DIFlagEnumClass, elements: !64, identifier: "_ZTS2E9")
+!64 = !{!65, !66}
+!65 = !DIEnumerator(name: "A9", value: -128)
+!66 = !DIEnumerator(name: "B9", value: 127)
+; CHECK: DW_TAG_enumeration_type
+; CHECK-NOT: DW_AT_type
+; CHECK-NOT: DW_AT_enum_class
+; CHECK: DW_AT_name ("E9")
+
+!45 = !{!0, !46, !48, !50, !52, !54, !56, !58, !60, !67}
+!46 = !DIGlobalVariableExpression(var: !47, expr: !DIExpression())
+!47 = distinct !DIGlobalVariable(name: "x1", scope: !2, file: !3, line: 12, type: !10, isLocal: false, isDefinition: true)
+!48 = !DIGlobalVariableExpression(var: !49, expr: !DIExpression())
+!49 = distinct !DIGlobalVariable(name: "x2", scope: !2, file: !3, line: 21, type: !14, isLocal: false, isDefinition: true)
+!50 = !DIGlobalVariableExpression(var: !51, expr: !DIExpression())
+!51 = distinct !DIGlobalVariable(name: "x3", scope: !2, file: !3, line: 28, type: !19, isLocal: false, isDefinition: true)
+!52 = !DIGlobalVariableExpression(var: !53, expr: !DIExpression())
+!53 = distinct !DIGlobalVariable(name: "x4", scope: !2, file: !3, line: 34, type: !23, isLocal: false, isDefinition: true)
+!54 = !DIGlobalVariableExpression(var: !55, expr: !DIExpression())
+!55 = distinct !DIGlobalVariable(name: "x5", scope: !2, file: !3, line: 41, type: !28, isLocal: false, isDefinition: true)
+!56 = !DIGlobalVariableExpression(var: !57, expr: !DIExpression())
+!57 = distinct !DIGlobalVariable(name: "x6", scope: !2, file: !3, line: 50, type: !32, isLocal: false, isDefinition: true)
+!58 = !DIGlobalVariableExpression(var: !59, expr: !DIExpression())
+!59 = distinct !DIGlobalVariable(name: "x7", scope: !2, file: !3, line: 57, type: !37, isLocal: false, isDefinition: true)
+!60 = !DIGlobalVariableExpression(var: !61, expr: !DIExpression())
+!61 = distinct !DIGlobalVariable(name: "x8", scope: !2, file: !3, line: 63, type: !41, isLocal: false, isDefinition: true)
+!67 = !DIGlobalVariableExpression(var: !68, expr: !DIExpression())
+!68 = distinct !DIGlobalVariable(name: "x9", scope: !2, file: !3, line: 63, type: !63, isLocal: false, isDefinition: true)
+!62 = !{i32 2, !"Debug Info Version", i32 3}
\ No newline at end of file
diff --git a/llvm/test/DebugInfo/Generic/debug-info-enum.ll b/llvm/test/DebugInfo/Generic/debug-info-enum.ll
index 9af465d59b7d9..747e7909f2f2e 100644
--- a/llvm/test/DebugInfo/Generic/debug-info-enum.ll
+++ b/llvm/test/DebugInfo/Generic/debug-info-enum.ll
@@ -9,10 +9,8 @@
; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s --check-prefixes=CHECK,CHECK-DW4,CHECK-TYPE
; RUN: llc -debugger-tune=gdb -dwarf-version=3 -filetype=obj -o %t.o < %s
; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s --check-prefixes=CHECK,CHECK-TYPE
-; RUN: llc -debugger-tune=gdb -dwarf-version=2 -filetype=obj -o %t.o < %s
-; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s --check-prefixes=CHECK,CHECK-TYPE
-; RUN: llc -debugger-tune=gdb -dwarf-version=2 -strict-dwarf=true -filetype=obj -o %t.o < %s
-; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s --check-prefixes=CHECK,CHECK-DW2-STRICT
+
+; For dwarf-version=2 tests on 32-bit targets, see debug-info-enum-32bit.ll
@x0 = global i8 0, align 1, !dbg !0
@x1 = global i8 0, align 1, !dbg !46
diff --git a/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1-32bit.ll b/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1-32bit.ll
new file mode 100644
index 0000000000000..577b698e3840f
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1-32bit.ll
@@ -0,0 +1,80 @@
+; xfail this test on hexagon because at O2, instructions are bundled in packets
+; and DW_OP_lit13 is correctly omitted.
+; XFAIL: target=hexagon-{{.*}}
+
+; This file contains the dwarf-version=2 tests extracted from incorrect-variable-debugloc1.ll
+; DWARF v2 is incompatible with 64-bit XCOFF/AIX (requires DWARF64 format which needs DWARF v3+)
+
+; UNSUPPORTED: target=powerpc64{{.*}}-aix{{.*}}
+
+; RUN: %llc_dwarf -O2 -dwarf-version 2 -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF23
+
+; This is a test for PR21176.
+; DW_OP_const <const> doesn't describe a constant value, but a value at a constant address.
+; The proper way to describe a constant value is DW_OP_constu <const>, DW_OP_stack_value.
+; For values < 32 we emit the canonical DW_OP_lit<const>.
+
+; Generated with clang -S -emit-llvm -g -O2 test.cpp
+
+; extern int func();
+;
+; int main()
+; {
+; volatile int c = 13;
+; c = func();
+; return c;
+; }
+
+; CHECK: DW_TAG_variable
+; CHECK: DW_AT_location
+; CHECK-NOT: DW_AT
+; DWARF23: DW_OP_lit13{{$}}
+
+; Function Attrs: uwtable
+define i32 @main() #0 !dbg !4 {
+entry:
+ %c = alloca i32, align 4
+ tail call void @llvm.dbg.value(metadata i32 13, metadata !10, metadata !16), !dbg !17
+ store volatile i32 13, ptr %c, align 4, !dbg !18
+ %call = tail call i32 @_Z4funcv(), !dbg !19
+ tail call void @llvm.dbg.value(metadata i32 %call, metadata !10, metadata !16), !dbg !17
+ store volatile i32 %call, ptr %c, align 4, !dbg !19
+ tail call void @llvm.dbg.value(metadata ptr %c, metadata !10, metadata !21), !dbg !17
+ %c.0.c.0. = load volatile i32, ptr %c, align 4, !dbg !20
+ ret i32 %c.0.c.0., !dbg !20
+}
+
+declare i32 @_Z4funcv() #1
+
+; Function Attrs: nounwind readnone
+declare void @llvm.dbg.value(metadata, metadata, metadata) #2
+
+attributes #0 = { uwtable "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }
+attributes #1 = { "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }
+attributes #2 = { nounwind readnone }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!12, !13}
+!llvm.ident = !{!14}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.6.0 (trunk 223522)", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
+!1 = !DIFile(filename: "test.cpp", directory: "/home/kromanova/ngh/ToT_latest/llvm/test/DebugInfo")
+!2 = !{}
+!4 = distinct !DISubprogram(name: "main", line: 3, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 4, file: !1, scope: !5, type: !6, retainedNodes: !9)
+!5 = !DIFile(filename: "test.cpp", directory: "/home/kromanova/ngh/ToT_latest/llvm/test/DebugInfo")
+!6 = !DISubroutineType(types: !7)
+!7 = !{!8}
+!8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!9 = !{!10}
+!10 = !DILocalVariable(name: "c", line: 5, scope: !4, file: !5, type: !11)
+!11 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !8)
+!12 = !{i32 2, !"Dwarf Version", i32 2}
+!13 = !{i32 2, !"Debug Info Version", i32 3}
+!14 = !{!"clang version 3.6.0 (trunk 223522)"}
+!15 = !{i32 13}
+!16 = !DIExpression()
+!17 = !DILocation(line: 5, column: 16, scope: !4)
+!18 = !DILocation(line: 5, column: 3, scope: !4)
+!19 = !DILocation(line: 6, column: 7, scope: !4)
+!20 = !DILocation(line: 7, column: 3, scope: !4)
+!21 = !DIExpression(DW_OP_deref)
\ No newline at end of file
diff --git a/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1.ll b/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1.ll
index 9399eb7a15637..d01212e237aeb 100644
--- a/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1.ll
+++ b/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1.ll
@@ -2,10 +2,11 @@
; and DW_OP_lit13 is correctly omitted.
; XFAIL: target=hexagon-{{.*}}
-; RUN: %llc_dwarf -O2 -dwarf-version 2 -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF23
; RUN: %llc_dwarf -O2 -dwarf-version 3 -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF23
; RUN: %llc_dwarf -O2 -dwarf-version 4 -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF4
+; For dwarf-version=2 tests on 32-bit targets, see incorrect-variable-debugloc1-32bit.ll
+
; This is a test for PR21176.
; DW_OP_const <const> doesn't describe a constant value, but a value at a constant address.
; The proper way to describe a constant value is DW_OP_constu <const>, DW_OP_stack_value.
diff --git a/llvm/test/DebugInfo/Generic/restrict-32bit.ll b/llvm/test/DebugInfo/Generic/restrict-32bit.ll
new file mode 100644
index 0000000000000..b25bbe438ba3e
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/restrict-32bit.ll
@@ -0,0 +1,51 @@
+; This file contains the dwarf-version=2 tests extracted from restrict.ll
+; DWARF v2 is incompatible with 64-bit XCOFF/AIX (requires DWARF64 format which needs DWARF v3+)
+
+; UNSUPPORTED: target=powerpc64{{.*}}-aix{{.*}}
+
+; RUN: %llc_dwarf -dwarf-version=2 -O0 -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck --check-prefix=CHECK --check-prefix=V2 %s
+
+; CHECK: DW_AT_name ("dst")
+; V2: DW_AT_type ([[PTR:0x........]]
+; CHECK: [[PTR]]: DW_TAG_pointer_type
+; CHECK-NOT: DW_AT_type
+
+; Generated with clang from:
+; void foo(ptr __restrict__ dst) {
+; }
+
+
+; Function Attrs: nounwind uwtable
+define void @_Z3fooPv(ptr noalias %dst) #0 !dbg !4 {
+entry:
+ %dst.addr = alloca ptr, align 8
+ store ptr %dst, ptr %dst.addr, align 8
+ call void @llvm.dbg.declare(metadata ptr %dst.addr, metadata !13, metadata !DIExpression()), !dbg !14
+ ret void, !dbg !15
+}
+
+; Function Attrs: nounwind readnone
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }
+attributes #1 = { nounwind readnone }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!10, !11}
+!llvm.ident = !{!12}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
+!1 = !DIFile(filename: "restrict.c", directory: "/tmp/dbginfo")
+!2 = !{}
+!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooPv", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, retainedNodes: !2)
+!5 = !DIFile(filename: "restrict.c", directory: "/tmp/dbginfo")
+!6 = !DISubroutineType(types: !7)
+!7 = !{null, !8}
+!8 = !DIDerivedType(tag: DW_TAG_restrict_type, baseType: !9)
+!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null)
+!10 = !{i32 2, !"Dwarf Version", i32 4}
+!11 = !{i32 1, !"Debug Info Version", i32 3}
+!12 = !{!"clang version 3.5.0 "}
+!13 = !DILocalVariable(name: "dst", line: 1, arg: 1, scope: !4, file: !5, type: !8)
+!14 = !DILocation(line: 1, scope: !4)
+!15 = !DILocation(line: 2, scope: !4)
\ No newline at end of file
diff --git a/llvm/test/DebugInfo/Generic/restrict.ll b/llvm/test/DebugInfo/Generic/restrict.ll
index f508ec649d307..54682f8cca2ba 100644
--- a/llvm/test/DebugInfo/Generic/restrict.ll
+++ b/llvm/test/DebugInfo/Generic/restrict.ll
@@ -1,6 +1,7 @@
-; RUN: %llc_dwarf -dwarf-version=2 -O0 -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck --check-prefix=CHECK --check-prefix=V2 %s
; RUN: %llc_dwarf -dwarf-version=3 -O0 -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck --check-prefix=CHECK --check-prefix=V3 %s
+; For dwarf-version=2 tests on 32-bit targets, see restrict-32bit.ll
+
; CHECK: DW_AT_name ("dst")
; V2: DW_AT_type ([[PTR:0x........]]
; V3: DW_AT_type ([[RESTRICT:0x........]]
>From d4e4c5e5be1c40dbbc130df42742626f25523dcb Mon Sep 17 00:00:00 2001
From: Lei Huang <lei at ca.ibm.com>
Date: Thu, 2 Apr 2026 09:14:50 -0400
Subject: [PATCH 2/3] apply Hubert's suggestions
---
.../Generic/debug-info-enum-32bit.ll | 210 ------------------
.../Generic/debug-info-enum-dwarf2.ll | 16 ++
.../test/DebugInfo/Generic/debug-info-enum.ll | 2 +-
.../incorrect-variable-debugloc1-32bit.ll | 80 -------
.../incorrect-variable-debugloc1-dwarf2.ll | 10 +
.../Generic/incorrect-variable-debugloc1.ll | 2 +-
llvm/test/DebugInfo/Generic/restrict-32bit.ll | 51 -----
.../test/DebugInfo/Generic/restrict-dwarf2.ll | 6 +
llvm/test/DebugInfo/Generic/restrict.ll | 2 +-
9 files changed, 35 insertions(+), 344 deletions(-)
delete mode 100644 llvm/test/DebugInfo/Generic/debug-info-enum-32bit.ll
create mode 100644 llvm/test/DebugInfo/Generic/debug-info-enum-dwarf2.ll
delete mode 100644 llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1-32bit.ll
create mode 100644 llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1-dwarf2.ll
delete mode 100644 llvm/test/DebugInfo/Generic/restrict-32bit.ll
create mode 100644 llvm/test/DebugInfo/Generic/restrict-dwarf2.ll
diff --git a/llvm/test/DebugInfo/Generic/debug-info-enum-32bit.ll b/llvm/test/DebugInfo/Generic/debug-info-enum-32bit.ll
deleted file mode 100644
index 108e7b3c35f49..0000000000000
--- a/llvm/test/DebugInfo/Generic/debug-info-enum-32bit.ll
+++ /dev/null
@@ -1,210 +0,0 @@
-; Test enumeration representation in DWARF debug info for 32-bit targets:
-; * test value representation for each possible underlying integer type
-; * test the integer type is as expected
-; * test the DW_AT_enum_class attribute is present (resp. absent) as expected.
-; * test that DW_AT_type is present for v3 and greater, and v2 when strict DWARF
-; is not enabled.
-
-; This file contains the dwarf-version=2 tests extracted from debug-info-enum.ll
-; DWARF v2 is incompatible with 64-bit XCOFF/AIX (requires DWARF64 format which needs DWARF v3+)
-
-; UNSUPPORTED: target=powerpc64{{.*}}-aix{{.*}}
-
-; RUN: llc -debugger-tune=gdb -dwarf-version=2 -filetype=obj -o %t.o < %s
-; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s --check-prefixes=CHECK,CHECK-TYPE
-; RUN: llc -debugger-tune=gdb -dwarf-version=2 -strict-dwarf=true -filetype=obj -o %t.o < %s
-; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s --check-prefixes=CHECK,CHECK-DW2-STRICT
-
- at x0 = global i8 0, align 1, !dbg !0
- at x1 = global i8 0, align 1, !dbg !46
- at x2 = global i16 0, align 2, !dbg !48
- at x3 = global i16 0, align 2, !dbg !50
- at x4 = global i32 0, align 4, !dbg !52
- at x5 = global i32 0, align 4, !dbg !54
- at x6 = global i64 0, align 8, !dbg !56
- at x7 = global i64 0, align 8, !dbg !58
- at x8 = global i32 0, align 4, !dbg !60
-
-!llvm.dbg.cu = !{!2}
-!llvm.module.flags = !{!62}
-
-!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
-!1 = distinct !DIGlobalVariable(name: "x0", scope: !2, file: !3, line: 5, type: !5, isLocal: false, isDefinition: true)
-!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 7.0.0 (/data/src/llvm/tools/clang 0c08d9830124a75675348b4eeb47256f3da6693d) (/data/src/llvm cf29510f52faa77b98510cd53276f564d1f4f41f)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !45)
-!3 = !DIFile(filename: "/data/src/llvm-dev/tools/clang/test/CodeGen/debug-info-enum.cpp", directory: "/work/build/clang-dev")
-!4 = !{!5, !10, !14, !19, !23, !28, !32, !37, !41}
-
-; Test enumeration with a fixed "signed char" underlying type.
-!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E0", file: !3, line: 2, baseType: !6, size: 8, flags: DIFlagEnumClass, elements: !7, identifier: "_ZTS2E0")
-!6 = !DIBasicType(name: "signed char", size: 8, encoding: DW_ATE_signed_char)
-!7 = !{!8, !9}
-!8 = !DIEnumerator(name: "A0", value: -128)
-!9 = !DIEnumerator(name: "B0", value: 127)
-; CHECK: DW_TAG_enumeration_type
-; CHECK-DW2-STRICT-NOT: DW_AT_type
-; CHECK-TYPE: DW_AT_type{{.*}}"signed char"
-; CHECK-NOT: DW_AT_enum_class
-; CHECK: DW_AT_name ("E0")
-; CHECK: DW_TAG_enumerator
-; CHECK: DW_AT_name ("A0")
-; CHECK-NEXT: DW_AT_const_value (-128)
-; CHECK: DW_TAG_enumerator
-; CHECK: DW_AT_name ("B0")
-; CHECK-NEXT: DW_AT_const_value (127)
-
-; Test enumeration with a fixed "unsigned char" underlying type.
-!10 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E1", file: !3, line: 12, baseType: !11, size: 8, flags: DIFlagEnumClass, elements: !12, identifier: "_ZTS2E1")
-!11 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)
-!12 = !{!13}
-!13 = !DIEnumerator(name: "A1", value: 255, isUnsigned: true)
-; CHECK: DW_TAG_enumeration_type
-; CHECK-DW2-STRICT-NOT: DW_AT_type
-; CHECK-TYPE: DW_AT_type{{.*}}"unsigned char"
-; CHECK-NOT: DW_AT_enum_class
-; CHECK: DW_AT_name ("E1")
-; CHECK: DW_TAG_enumerator
-; CHECK: DW_AT_name ("A1")
-; CHECK-NEXT: DW_AT_const_value (255)
-
-; Test enumeration with a fixed "short" underlying type.
-!14 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E2", file: !3, line: 18, baseType: !15, size: 16, flags: DIFlagEnumClass, elements: !16, identifier: "_ZTS2E2")
-!15 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
-!16 = !{!17, !18}
-!17 = !DIEnumerator(name: "A2", value: -32768)
-!18 = !DIEnumerator(name: "B2", value: 32767)
-; CHECK: DW_TAG_enumeration_type
-; CHECK-DW2-STRICT-NOT: DW_AT_type
-; CHECK-TYPE: DW_AT_type{{.*}} "short"
-; CHECK-NOT: DW_AT_enum_class
-; CHECK: DW_AT_name ("E2")
-; CHECK: DW_TAG_enumerator
-; CHECK: DW_AT_name ("A2")
-; CHECK-NEXT: DW_AT_const_value (-32768)
-; CHECK: DW_TAG_enumerator
-; CHECK: DW_AT_name ("B2")
-; CHECK-NEXT: DW_AT_const_value (32767)
-
-; Test enumeration with a fixed "unsigned short" underlying type.
-!19 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E3", file: !3, line: 28, baseType: !20, size: 16, flags: DIFlagEnumClass, elements: !21, identifier: "_ZTS2E3")
-!20 = !DIBasicType(name: "unsigned short", size: 16, encoding: DW_ATE_unsigned)
-!21 = !{!22}
-!22 = !DIEnumerator(name: "A3", value: 65535, isUnsigned: true)
-; CHECK: DW_TAG_enumeration_type
-; CHECK-DW2-STRICT-NOT: DW_AT_type
-; CHECK-TYPE DW_AT_type{{.*}}"unsigned short"
-; CHECK-NOT: DW_AT_enum_class
-; CHECK: DW_AT_name ("E3")
-; CHECK: DW_TAG_enumerator
-; CHECK: DW_AT_name ("A3")
-; CHECK-NEXT: DW_AT_const_value (65535)
-
-; Test enumeration with a fixed "int" underlying type.
-!23 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E4", file: !3, line: 34, baseType: !24, size: 32, flags: DIFlagEnumClass, elements: !25, identifier: "_ZTS2E4")
-!24 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!25 = !{!26, !27}
-!26 = !DIEnumerator(name: "A4", value: -2147483648)
-!27 = !DIEnumerator(name: "B4", value: 2147483647)
-; CHECK: DW_TAG_enumeration_type
-; CHECK-DW2-STRICT-NOT: DW_AT_type
-; CHECK-TYPE: DW_AT_type{{.*}}"int"
-; CHECK-NOT: DW_AT_enum_class
-; CHECK: DW_AT_name ("E4")
-; CHECK: DW_TAG_enumerator
-; CHECK: DW_AT_name ("A4")
-; CHECK-NEXT: DW_AT_const_value (-2147483648)
-; CHECK: DW_TAG_enumerator
-; CHECK: DW_AT_name ("B4")
-; CHECK-NEXT: DW_AT_const_value (2147483647)
-
-; Test enumeration with a fixed "unsigend int" underlying type.
-!28 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E5", file: !3, line: 41, baseType: !29, size: 32, flags: DIFlagEnumClass, elements: !30, identifier: "_ZTS2E5")
-!29 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
-!30 = !{!31}
-!31 = !DIEnumerator(name: "A5", value: 4294967295, isUnsigned: true)
-; CHECK: DW_TAG_enumeration_type
-; CHECK-DW2-STRICT-NOT: DW_AT_type
-; CHECK-TYPE: DW_AT_type{{.*}}"unsigned int"
-; CHECK-NOT: DW_AT_enum_class
-; CHECK: DW_AT_name ("E5")
-; CHECK: DW_TAG_enumerator
-; CHECK: DW_AT_name ("A5")
-; CHECK-NEXT: DW_AT_const_value (4294967295)
-
-; Test enumeration with a fixed "long long" underlying type.
-!32 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E6", file: !3, line: 47, baseType: !33, size: 64, flags: DIFlagEnumClass, elements: !34, identifier: "_ZTS2E6")
-!33 = !DIBasicType(name: "long long int", size: 64, encoding: DW_ATE_signed)
-!34 = !{!35, !36}
-!35 = !DIEnumerator(name: "A6", value: -9223372036854775808)
-!36 = !DIEnumerator(name: "B6", value: 9223372036854775807)
-; CHECK: DW_TAG_enumeration_type
-; CHECK-DW2-STRICT-NOT: DW_AT_type
-; CHECK-TYPE: DW_AT_type{{.*}}"long long int"
-; CHECK-NOT: DW_AT_enum_class
-; CHECK: DW_AT_name ("E6")
-; CHECK: DW_TAG_enumerator
-; CHECK: DW_AT_name ("A6")
-; CHECK-NEXT: DW_AT_const_value (-9223372036854775808)
-; CHECK: DW_TAG_enumerator
-; CHECK: DW_AT_name ("B6")
-; CHECK-NEXT: DW_AT_const_value (9223372036854775807)
-
-; Test enumeration with a fixed "unsigned long long" underlying type.
-!37 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E7", file: !3, line: 57, baseType: !38, size: 64, flags: DIFlagEnumClass, elements: !39, identifier: "_ZTS2E7")
-!38 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned)
-!39 = !{!40}
-!40 = !DIEnumerator(name: "A7", value: 18446744073709551615, isUnsigned: true)
-; CHECK: DW_TAG_enumeration_type
-; CHECK-DW2-STRICT-NOT: DW_AT_type
-; CHECK-TYPE: DW_AT_type{{.*}}"long long unsigned int"
-; CHECK-NOT: DW_AT_enum_class
-; CHECK: DW_AT_name ("E7")
-; CHECK: DW_TAG_enumerator
-; CHECK: DW_AT_name ("A7")
-; CHECK-NEXT: DW_AT_const_value (18446744073709551615)
-
-; Test enumeration without a fixed underlying type. The underlying type should
-; still be present (for DWARF >= 3), but the DW_AT_enum_class attribute should
-; be absent.
-!41 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E8", file: !3, line: 63, baseType: !24, size: 32, elements: !42, identifier: "_ZTS2E8")
-!42 = !{!43, !44}
-!43 = !DIEnumerator(name: "A8", value: -128)
-!44 = !DIEnumerator(name: "B8", value: 127)
-; CHECK: DW_TAG_enumeration_type
-; CHECK-DW2-STRICT-NOT: DW_AT_type
-; CHECK-TYPE: DW_AT_type{{.*}}"int"
-; CHECK-NOT: DW_AT_enum_class
-; CHECK: DW_AT_name ("E8")
-
-; Test enumeration without a fixed underlying type, but with the DIFlagEnumClass
-; set. The DW_AT_enum_class attribute should be absent. This behaviour is
-; intented to keep compatibilty with existing DWARF consumers, which may imply
-; the type is present whenever DW_AT_enum_class is set.
-!63 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E9", file: !3, line: 63, size: 32, flags: DIFlagEnumClass, elements: !64, identifier: "_ZTS2E9")
-!64 = !{!65, !66}
-!65 = !DIEnumerator(name: "A9", value: -128)
-!66 = !DIEnumerator(name: "B9", value: 127)
-; CHECK: DW_TAG_enumeration_type
-; CHECK-NOT: DW_AT_type
-; CHECK-NOT: DW_AT_enum_class
-; CHECK: DW_AT_name ("E9")
-
-!45 = !{!0, !46, !48, !50, !52, !54, !56, !58, !60, !67}
-!46 = !DIGlobalVariableExpression(var: !47, expr: !DIExpression())
-!47 = distinct !DIGlobalVariable(name: "x1", scope: !2, file: !3, line: 12, type: !10, isLocal: false, isDefinition: true)
-!48 = !DIGlobalVariableExpression(var: !49, expr: !DIExpression())
-!49 = distinct !DIGlobalVariable(name: "x2", scope: !2, file: !3, line: 21, type: !14, isLocal: false, isDefinition: true)
-!50 = !DIGlobalVariableExpression(var: !51, expr: !DIExpression())
-!51 = distinct !DIGlobalVariable(name: "x3", scope: !2, file: !3, line: 28, type: !19, isLocal: false, isDefinition: true)
-!52 = !DIGlobalVariableExpression(var: !53, expr: !DIExpression())
-!53 = distinct !DIGlobalVariable(name: "x4", scope: !2, file: !3, line: 34, type: !23, isLocal: false, isDefinition: true)
-!54 = !DIGlobalVariableExpression(var: !55, expr: !DIExpression())
-!55 = distinct !DIGlobalVariable(name: "x5", scope: !2, file: !3, line: 41, type: !28, isLocal: false, isDefinition: true)
-!56 = !DIGlobalVariableExpression(var: !57, expr: !DIExpression())
-!57 = distinct !DIGlobalVariable(name: "x6", scope: !2, file: !3, line: 50, type: !32, isLocal: false, isDefinition: true)
-!58 = !DIGlobalVariableExpression(var: !59, expr: !DIExpression())
-!59 = distinct !DIGlobalVariable(name: "x7", scope: !2, file: !3, line: 57, type: !37, isLocal: false, isDefinition: true)
-!60 = !DIGlobalVariableExpression(var: !61, expr: !DIExpression())
-!61 = distinct !DIGlobalVariable(name: "x8", scope: !2, file: !3, line: 63, type: !41, isLocal: false, isDefinition: true)
-!67 = !DIGlobalVariableExpression(var: !68, expr: !DIExpression())
-!68 = distinct !DIGlobalVariable(name: "x9", scope: !2, file: !3, line: 63, type: !63, isLocal: false, isDefinition: true)
-!62 = !{i32 2, !"Debug Info Version", i32 3}
\ No newline at end of file
diff --git a/llvm/test/DebugInfo/Generic/debug-info-enum-dwarf2.ll b/llvm/test/DebugInfo/Generic/debug-info-enum-dwarf2.ll
new file mode 100644
index 0000000000000..23441a9a4ac09
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/debug-info-enum-dwarf2.ll
@@ -0,0 +1,16 @@
+; Test enumeration representation in DWARF debug info for DWARF v2:
+; * test value representation for each possible underlying integer type
+; * test the integer type is as expected
+; * test the DW_AT_enum_class attribute is present (resp. absent) as expected.
+; * test that DW_AT_type is present for v3 and greater, and v2 when strict DWARF
+; is not enabled.
+
+; This file contains the dwarf-version=2 tests extracted from debug-info-enum.ll
+; DWARF v2 is incompatible with 64-bit XCOFF/AIX (requires DWARF64 format which needs DWARF v3+)
+
+; UNSUPPORTED: target=powerpc64{{.*}}-aix{{.*}}
+
+; RUN: llc -debugger-tune=gdb -dwarf-version=2 -filetype=obj -o %t.o < %S/debug-info-enum.ll
+; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %S/debug-info-enum.ll --check-prefixes=CHECK,CHECK-TYPE
+; RUN: llc -debugger-tune=gdb -dwarf-version=2 -strict-dwarf=true -filetype=obj -o %t.o < %S/debug-info-enum.ll
+; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %S/debug-info-enum.ll --check-prefixes=CHECK,CHECK-DW2-STRICT
diff --git a/llvm/test/DebugInfo/Generic/debug-info-enum.ll b/llvm/test/DebugInfo/Generic/debug-info-enum.ll
index 747e7909f2f2e..15ff570bb1796 100644
--- a/llvm/test/DebugInfo/Generic/debug-info-enum.ll
+++ b/llvm/test/DebugInfo/Generic/debug-info-enum.ll
@@ -10,7 +10,7 @@
; RUN: llc -debugger-tune=gdb -dwarf-version=3 -filetype=obj -o %t.o < %s
; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s --check-prefixes=CHECK,CHECK-TYPE
-; For dwarf-version=2 tests on 32-bit targets, see debug-info-enum-32bit.ll
+; For dwarf-version=2 tests, see debug-info-enum-dwarf2.ll
@x0 = global i8 0, align 1, !dbg !0
@x1 = global i8 0, align 1, !dbg !46
diff --git a/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1-32bit.ll b/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1-32bit.ll
deleted file mode 100644
index 577b698e3840f..0000000000000
--- a/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1-32bit.ll
+++ /dev/null
@@ -1,80 +0,0 @@
-; xfail this test on hexagon because at O2, instructions are bundled in packets
-; and DW_OP_lit13 is correctly omitted.
-; XFAIL: target=hexagon-{{.*}}
-
-; This file contains the dwarf-version=2 tests extracted from incorrect-variable-debugloc1.ll
-; DWARF v2 is incompatible with 64-bit XCOFF/AIX (requires DWARF64 format which needs DWARF v3+)
-
-; UNSUPPORTED: target=powerpc64{{.*}}-aix{{.*}}
-
-; RUN: %llc_dwarf -O2 -dwarf-version 2 -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF23
-
-; This is a test for PR21176.
-; DW_OP_const <const> doesn't describe a constant value, but a value at a constant address.
-; The proper way to describe a constant value is DW_OP_constu <const>, DW_OP_stack_value.
-; For values < 32 we emit the canonical DW_OP_lit<const>.
-
-; Generated with clang -S -emit-llvm -g -O2 test.cpp
-
-; extern int func();
-;
-; int main()
-; {
-; volatile int c = 13;
-; c = func();
-; return c;
-; }
-
-; CHECK: DW_TAG_variable
-; CHECK: DW_AT_location
-; CHECK-NOT: DW_AT
-; DWARF23: DW_OP_lit13{{$}}
-
-; Function Attrs: uwtable
-define i32 @main() #0 !dbg !4 {
-entry:
- %c = alloca i32, align 4
- tail call void @llvm.dbg.value(metadata i32 13, metadata !10, metadata !16), !dbg !17
- store volatile i32 13, ptr %c, align 4, !dbg !18
- %call = tail call i32 @_Z4funcv(), !dbg !19
- tail call void @llvm.dbg.value(metadata i32 %call, metadata !10, metadata !16), !dbg !17
- store volatile i32 %call, ptr %c, align 4, !dbg !19
- tail call void @llvm.dbg.value(metadata ptr %c, metadata !10, metadata !21), !dbg !17
- %c.0.c.0. = load volatile i32, ptr %c, align 4, !dbg !20
- ret i32 %c.0.c.0., !dbg !20
-}
-
-declare i32 @_Z4funcv() #1
-
-; Function Attrs: nounwind readnone
-declare void @llvm.dbg.value(metadata, metadata, metadata) #2
-
-attributes #0 = { uwtable "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }
-attributes #1 = { "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }
-attributes #2 = { nounwind readnone }
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!12, !13}
-!llvm.ident = !{!14}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.6.0 (trunk 223522)", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
-!1 = !DIFile(filename: "test.cpp", directory: "/home/kromanova/ngh/ToT_latest/llvm/test/DebugInfo")
-!2 = !{}
-!4 = distinct !DISubprogram(name: "main", line: 3, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 4, file: !1, scope: !5, type: !6, retainedNodes: !9)
-!5 = !DIFile(filename: "test.cpp", directory: "/home/kromanova/ngh/ToT_latest/llvm/test/DebugInfo")
-!6 = !DISubroutineType(types: !7)
-!7 = !{!8}
-!8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
-!9 = !{!10}
-!10 = !DILocalVariable(name: "c", line: 5, scope: !4, file: !5, type: !11)
-!11 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !8)
-!12 = !{i32 2, !"Dwarf Version", i32 2}
-!13 = !{i32 2, !"Debug Info Version", i32 3}
-!14 = !{!"clang version 3.6.0 (trunk 223522)"}
-!15 = !{i32 13}
-!16 = !DIExpression()
-!17 = !DILocation(line: 5, column: 16, scope: !4)
-!18 = !DILocation(line: 5, column: 3, scope: !4)
-!19 = !DILocation(line: 6, column: 7, scope: !4)
-!20 = !DILocation(line: 7, column: 3, scope: !4)
-!21 = !DIExpression(DW_OP_deref)
\ No newline at end of file
diff --git a/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1-dwarf2.ll b/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1-dwarf2.ll
new file mode 100644
index 0000000000000..d2d9aa3ac7fd5
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1-dwarf2.ll
@@ -0,0 +1,10 @@
+; xfail this test on hexagon because at O2, instructions are bundled in packets
+; and DW_OP_lit13 is correctly omitted.
+; XFAIL: target=hexagon-{{.*}}
+
+; This file contains the dwarf-version=2 tests extracted from incorrect-variable-debugloc1.ll
+; DWARF v2 is incompatible with 64-bit XCOFF/AIX (requires DWARF64 format which needs DWARF v3+)
+
+; UNSUPPORTED: target=powerpc64{{.*}}-aix{{.*}}
+
+; RUN: %llc_dwarf -O2 -dwarf-version 2 -filetype=obj < %S/incorrect-variable-debugloc1.ll | llvm-dwarfdump - | FileCheck %S/incorrect-variable-debugloc1.ll --check-prefix=DWARF23
diff --git a/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1.ll b/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1.ll
index d01212e237aeb..a02cdebe013b9 100644
--- a/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1.ll
+++ b/llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1.ll
@@ -5,7 +5,7 @@
; RUN: %llc_dwarf -O2 -dwarf-version 3 -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF23
; RUN: %llc_dwarf -O2 -dwarf-version 4 -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF4
-; For dwarf-version=2 tests on 32-bit targets, see incorrect-variable-debugloc1-32bit.ll
+; For dwarf-version=2 tests, see incorrect-variable-debugloc1-dwarf2.ll
; This is a test for PR21176.
; DW_OP_const <const> doesn't describe a constant value, but a value at a constant address.
diff --git a/llvm/test/DebugInfo/Generic/restrict-32bit.ll b/llvm/test/DebugInfo/Generic/restrict-32bit.ll
deleted file mode 100644
index b25bbe438ba3e..0000000000000
--- a/llvm/test/DebugInfo/Generic/restrict-32bit.ll
+++ /dev/null
@@ -1,51 +0,0 @@
-; This file contains the dwarf-version=2 tests extracted from restrict.ll
-; DWARF v2 is incompatible with 64-bit XCOFF/AIX (requires DWARF64 format which needs DWARF v3+)
-
-; UNSUPPORTED: target=powerpc64{{.*}}-aix{{.*}}
-
-; RUN: %llc_dwarf -dwarf-version=2 -O0 -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck --check-prefix=CHECK --check-prefix=V2 %s
-
-; CHECK: DW_AT_name ("dst")
-; V2: DW_AT_type ([[PTR:0x........]]
-; CHECK: [[PTR]]: DW_TAG_pointer_type
-; CHECK-NOT: DW_AT_type
-
-; Generated with clang from:
-; void foo(ptr __restrict__ dst) {
-; }
-
-
-; Function Attrs: nounwind uwtable
-define void @_Z3fooPv(ptr noalias %dst) #0 !dbg !4 {
-entry:
- %dst.addr = alloca ptr, align 8
- store ptr %dst, ptr %dst.addr, align 8
- call void @llvm.dbg.declare(metadata ptr %dst.addr, metadata !13, metadata !DIExpression()), !dbg !14
- ret void, !dbg !15
-}
-
-; Function Attrs: nounwind readnone
-declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
-
-attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }
-attributes #1 = { nounwind readnone }
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!10, !11}
-!llvm.ident = !{!12}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
-!1 = !DIFile(filename: "restrict.c", directory: "/tmp/dbginfo")
-!2 = !{}
-!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooPv", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, retainedNodes: !2)
-!5 = !DIFile(filename: "restrict.c", directory: "/tmp/dbginfo")
-!6 = !DISubroutineType(types: !7)
-!7 = !{null, !8}
-!8 = !DIDerivedType(tag: DW_TAG_restrict_type, baseType: !9)
-!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null)
-!10 = !{i32 2, !"Dwarf Version", i32 4}
-!11 = !{i32 1, !"Debug Info Version", i32 3}
-!12 = !{!"clang version 3.5.0 "}
-!13 = !DILocalVariable(name: "dst", line: 1, arg: 1, scope: !4, file: !5, type: !8)
-!14 = !DILocation(line: 1, scope: !4)
-!15 = !DILocation(line: 2, scope: !4)
\ No newline at end of file
diff --git a/llvm/test/DebugInfo/Generic/restrict-dwarf2.ll b/llvm/test/DebugInfo/Generic/restrict-dwarf2.ll
new file mode 100644
index 0000000000000..55e7e7a2dfa76
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/restrict-dwarf2.ll
@@ -0,0 +1,6 @@
+; This file contains the dwarf-version=2 tests extracted from restrict.ll
+; DWARF v2 is incompatible with 64-bit XCOFF/AIX (requires DWARF64 format which needs DWARF v3+)
+
+; UNSUPPORTED: target=powerpc64{{.*}}-aix{{.*}}
+
+; RUN: %llc_dwarf -dwarf-version=2 -O0 -filetype=obj < %S/restrict.ll | llvm-dwarfdump -debug-info - | FileCheck --check-prefix=CHECK --check-prefix=V2 %S/restrict.ll
diff --git a/llvm/test/DebugInfo/Generic/restrict.ll b/llvm/test/DebugInfo/Generic/restrict.ll
index 54682f8cca2ba..f6876fe7c69f8 100644
--- a/llvm/test/DebugInfo/Generic/restrict.ll
+++ b/llvm/test/DebugInfo/Generic/restrict.ll
@@ -1,6 +1,6 @@
; RUN: %llc_dwarf -dwarf-version=3 -O0 -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck --check-prefix=CHECK --check-prefix=V3 %s
-; For dwarf-version=2 tests on 32-bit targets, see restrict-32bit.ll
+; For dwarf-version=2 tests, see restrict-dwarf2.ll
; CHECK: DW_AT_name ("dst")
; V2: DW_AT_type ([[PTR:0x........]]
>From 5d7daff4b1c6055e7a0c0a98f8c5648456fc4ac6 Mon Sep 17 00:00:00 2001
From: Lei Huang <lei at ca.ibm.com>
Date: Thu, 2 Apr 2026 00:01:35 -0500
Subject: [PATCH 3/3] update comment
---
llvm/test/DebugInfo/Generic/debug-info-enum-dwarf2.ll | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/test/DebugInfo/Generic/debug-info-enum-dwarf2.ll b/llvm/test/DebugInfo/Generic/debug-info-enum-dwarf2.ll
index 23441a9a4ac09..0637473156aa2 100644
--- a/llvm/test/DebugInfo/Generic/debug-info-enum-dwarf2.ll
+++ b/llvm/test/DebugInfo/Generic/debug-info-enum-dwarf2.ll
@@ -2,8 +2,7 @@
; * test value representation for each possible underlying integer type
; * test the integer type is as expected
; * test the DW_AT_enum_class attribute is present (resp. absent) as expected.
-; * test that DW_AT_type is present for v3 and greater, and v2 when strict DWARF
-; is not enabled.
+; * test that DW_AT_type is present for v2 when strict DWARF is not enabled.
; This file contains the dwarf-version=2 tests extracted from debug-info-enum.ll
; DWARF v2 is incompatible with 64-bit XCOFF/AIX (requires DWARF64 format which needs DWARF v3+)
More information about the llvm-commits
mailing list