Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 47324cf

Browse files
committedSep 15, 2023
Reapply [Verifier] Sanity check alloca size against DILocalVariable fragment size
Reapply after fixing a clang bug this exposed in D158972 and adjusting a number of tests that failed for 32-bit targets. ----- Add a check that the DILocalVariable fragment size in dbg.declare does not exceed the size of the alloca. This would have caught the invalid debuginfo regenerated by rustc in #64149. Differential Revision: https://reviews.llvm.org/D158743
1 parent 303eb50 commit 47324cf

20 files changed

+225
-204
lines changed
 

‎llvm/lib/IR/Verifier.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6298,6 +6298,20 @@ void Verifier::visitDbgIntrinsic(StringRef Kind, DbgVariableIntrinsic &DII) {
62986298
CheckDI(isType(Var->getRawType()), "invalid type ref", Var,
62996299
Var->getRawType());
63006300
verifyFnArgs(DII);
6301+
6302+
if (auto *Declare = dyn_cast<DbgDeclareInst>(&DII)) {
6303+
if (auto *Alloca = dyn_cast_or_null<AllocaInst>(Declare->getAddress())) {
6304+
DIExpression *Expr = Declare->getExpression();
6305+
std::optional<uint64_t> FragSize = Declare->getFragmentSizeInBits();
6306+
std::optional<TypeSize> AllocSize = Alloca->getAllocationSizeInBits(DL);
6307+
if (FragSize && AllocSize && !AllocSize->isScalable() &&
6308+
!Expr->isComplex()) {
6309+
CheckDI(*FragSize <= AllocSize->getFixedValue(),
6310+
"llvm.dbg.declare has larger fragment size than alloca size ",
6311+
&DII);
6312+
}
6313+
}
6314+
}
63016315
}
63026316

63036317
void Verifier::visitDbgLabelIntrinsic(StringRef Kind, DbgLabelInst &DLI) {

‎llvm/test/CodeGen/ARM/stack-frame-layout-remarks.ll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -236,19 +236,19 @@ attributes #2 = { ssp "stack-protector-buffer-size"="5" "frame-pointer"="all" }
236236
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !4, splitDebugInlining: false, nameTableKind: None)
237237
!3 = !DIFile(filename: "dot.c", directory: "")
238238
!4 = !{!5, !6, !10, !13}
239-
!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
240-
!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)
241-
!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Array", file: !3, line: 3, size: 128, elements: !8)
239+
!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 32)
240+
!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32)
241+
!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Array", file: !3, line: 3, size: 64, elements: !8)
242242
!8 = !{!9, !12}
243-
!9 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !7, file: !3, line: 4, baseType: !10, size: 64)
244-
!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)
243+
!9 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !7, file: !3, line: 4, baseType: !10, size: 32)
244+
!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 32)
245245
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
246-
!12 = !DIDerivedType(tag: DW_TAG_member, name: "size", scope: !7, file: !3, line: 5, baseType: !11, size: 32, offset: 64)
247-
!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64)
248-
!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Result", file: !3, line: 8, size: 128, elements: !15)
246+
!12 = !DIDerivedType(tag: DW_TAG_member, name: "size", scope: !7, file: !3, line: 5, baseType: !11, size: 32, offset: 32)
247+
!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 32)
248+
!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Result", file: !3, line: 8, size: 64, elements: !15)
249249
!15 = !{!16, !17}
250-
!16 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !14, file: !3, line: 9, baseType: !6, size: 64)
251-
!17 = !DIDerivedType(tag: DW_TAG_member, name: "sum", scope: !14, file: !3, line: 10, baseType: !11, size: 32, offset: 64)
250+
!16 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !14, file: !3, line: 9, baseType: !6, size: 32)
251+
!17 = !DIDerivedType(tag: DW_TAG_member, name: "sum", scope: !14, file: !3, line: 10, baseType: !11, size: 32, offset: 32)
252252
!18 = !{i32 7, !"Dwarf Version", i32 5}
253253
!19 = !{i32 2, !"Debug Info Version", i32 3}
254254
!20 = !{i32 1, !"wchar_size", i32 4}

‎llvm/test/CodeGen/BPF/warn-stack.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
;; CHECK-NOT: nowarn
44
define void @nowarn() local_unnamed_addr #0 !dbg !6 {
5-
%1 = alloca [504 x i8], align 1
6-
call void @llvm.lifetime.start.p0(i64 504, ptr nonnull %1) #4, !dbg !15
5+
%1 = alloca [511 x i8], align 1
6+
call void @llvm.lifetime.start.p0(i64 511, ptr nonnull %1) #4, !dbg !15
77
tail call void @llvm.dbg.declare(metadata ptr %1, metadata !10, metadata !16), !dbg !17
88
call void @doit(ptr nonnull %1) #4, !dbg !18
9-
call void @llvm.lifetime.end.p0(i64 504, ptr nonnull %1) #4, !dbg !19
9+
call void @llvm.lifetime.end.p0(i64 511, ptr nonnull %1) #4, !dbg !19
1010
ret void, !dbg !19
1111
}
1212

‎llvm/test/CodeGen/X86/stack-frame-layout-remarks.ll renamed to ‎llvm/test/CodeGen/X86/stack-frame-layout-remarks-32.ll

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,16 @@
11
; Test remark output for stack-frame-layout
22

3-
; ensure basic output works
4-
; RUN: llc -mcpu=corei7 -O1 -pass-remarks-analysis=stack-frame-layout < %s 2>&1 >/dev/null | FileCheck %s
5-
6-
; check additional slots are displayed when stack is not optimized
7-
; RUN: llc -mcpu=corei7 -O0 -pass-remarks-analysis=stack-frame-layout < %s 2>&1 >/dev/null | FileCheck %s --check-prefix=NO_COLORING
8-
93
; check more complex cases
104
; 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
115

126
; check output without debug info
137
; 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
148

15-
target triple = "x86_64-unknown-linux-gnu"
9+
target triple = "i386-unknown-linux-gnu"
1610

1711
@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
1812
declare i32 @printf(ptr, ...)
1913

20-
; CHECK: Function: stackSizeWarning
21-
; CHECK: Offset: [SP-88], Type: Variable, Align: 16, Size: 80
22-
; CHECK: buffer @ frame-diags.c:30
23-
; NO_COLORING: Offset: [SP-168], Type: Variable, Align: 16, Size: 80
24-
; CHECK: buffer2 @ frame-diags.c:33
25-
define void @stackSizeWarning() {
26-
entry:
27-
%buffer = alloca [80 x i8], align 16
28-
%buffer2 = alloca [80 x i8], align 16
29-
call void @llvm.dbg.declare(metadata ptr %buffer, metadata !25, metadata !DIExpression()), !dbg !39
30-
call void @llvm.dbg.declare(metadata ptr %buffer2, metadata !31, metadata !DIExpression()), !dbg !40
31-
ret void
32-
}
33-
3414
; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
3515
declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
3616

@@ -208,7 +188,7 @@ entry:
208188
}
209189

210190
; uselistorder directives
211-
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 }
191+
uselistorder ptr @llvm.dbg.declare, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 16 }
212192

213193
attributes #0 = { nocallback nofree nosync nounwind readnone speculatable willreturn }
214194
attributes #1 = { "frame-pointer"="all" }
@@ -222,19 +202,19 @@ attributes #2 = { ssp "stack-protector-buffer-size"="5" "frame-pointer"="all" }
222202
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !4, splitDebugInlining: false, nameTableKind: None)
223203
!3 = !DIFile(filename: "dot.c", directory: "")
224204
!4 = !{!5, !6, !10, !13}
225-
!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
226-
!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)
227-
!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Array", file: !3, line: 3, size: 128, elements: !8)
205+
!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 32)
206+
!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32)
207+
!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Array", file: !3, line: 3, size: 64, elements: !8)
228208
!8 = !{!9, !12}
229-
!9 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !7, file: !3, line: 4, baseType: !10, size: 64)
230-
!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)
209+
!9 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !7, file: !3, line: 4, baseType: !10, size: 32)
210+
!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 32)
231211
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
232-
!12 = !DIDerivedType(tag: DW_TAG_member, name: "size", scope: !7, file: !3, line: 5, baseType: !11, size: 32, offset: 64)
233-
!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64)
234-
!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Result", file: !3, line: 8, size: 128, elements: !15)
212+
!12 = !DIDerivedType(tag: DW_TAG_member, name: "size", scope: !7, file: !3, line: 5, baseType: !11, size: 32, offset: 32)
213+
!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 32)
214+
!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Result", file: !3, line: 8, size: 64, elements: !15)
235215
!15 = !{!16, !17}
236-
!16 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !14, file: !3, line: 9, baseType: !6, size: 64)
237-
!17 = !DIDerivedType(tag: DW_TAG_member, name: "sum", scope: !14, file: !3, line: 10, baseType: !11, size: 32, offset: 64)
216+
!16 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !14, file: !3, line: 9, baseType: !6, size: 32)
217+
!17 = !DIDerivedType(tag: DW_TAG_member, name: "sum", scope: !14, file: !3, line: 10, baseType: !11, size: 32, offset: 32)
238218
!18 = !{i32 7, !"Dwarf Version", i32 5}
239219
!19 = !{i32 2, !"Debug Info Version", i32 3}
240220
!20 = !{i32 1, !"wchar_size", i32 4}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
; Test remark output for stack-frame-layout
2+
3+
; ensure basic output works
4+
; RUN: llc -mcpu=corei7 -O1 -pass-remarks-analysis=stack-frame-layout < %s 2>&1 >/dev/null | FileCheck %s
5+
6+
; check additional slots are displayed when stack is not optimized
7+
; RUN: llc -mcpu=corei7 -O0 -pass-remarks-analysis=stack-frame-layout < %s 2>&1 >/dev/null | FileCheck %s --check-prefix=NO_COLORING
8+
9+
target triple = "x86_64-unknown-linux-gnu"
10+
11+
@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
12+
declare i32 @printf(ptr, ...)
13+
14+
; CHECK: Function: stackSizeWarning
15+
; CHECK: Offset: [SP-88], Type: Variable, Align: 16, Size: 80
16+
; CHECK: buffer @ frame-diags.c:30
17+
; NO_COLORING: Offset: [SP-168], Type: Variable, Align: 16, Size: 80
18+
; CHECK: buffer2 @ frame-diags.c:33
19+
define void @stackSizeWarning() {
20+
entry:
21+
%buffer = alloca [80 x i8], align 16
22+
%buffer2 = alloca [80 x i8], align 16
23+
call void @llvm.dbg.declare(metadata ptr %buffer, metadata !25, metadata !DIExpression()), !dbg !39
24+
call void @llvm.dbg.declare(metadata ptr %buffer2, metadata !31, metadata !DIExpression()), !dbg !40
25+
ret void
26+
}
27+
28+
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
29+
declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
30+
31+
attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
32+
33+
!llvm.dbg.cu = !{!0, !2}
34+
!llvm.module.flags = !{!18, !19, !20, !21, !22, !23, !24}
35+
36+
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
37+
!1 = !DIFile(filename: "frame-diags.c", directory: "")
38+
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !4, splitDebugInlining: false, nameTableKind: None)
39+
!3 = !DIFile(filename: "dot.c", directory: "")
40+
!4 = !{!5, !6, !10, !13}
41+
!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
42+
!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)
43+
!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Array", file: !3, line: 3, size: 128, elements: !8)
44+
!8 = !{!9, !12}
45+
!9 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !7, file: !3, line: 4, baseType: !10, size: 64)
46+
!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)
47+
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
48+
!12 = !DIDerivedType(tag: DW_TAG_member, name: "size", scope: !7, file: !3, line: 5, baseType: !11, size: 32, offset: 64)
49+
!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64)
50+
!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Result", file: !3, line: 8, size: 128, elements: !15)
51+
!15 = !{!16, !17}
52+
!16 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !14, file: !3, line: 9, baseType: !6, size: 64)
53+
!17 = !DIDerivedType(tag: DW_TAG_member, name: "sum", scope: !14, file: !3, line: 10, baseType: !11, size: 32, offset: 64)
54+
!18 = !{i32 7, !"Dwarf Version", i32 5}
55+
!19 = !{i32 2, !"Debug Info Version", i32 3}
56+
!20 = !{i32 1, !"wchar_size", i32 4}
57+
!21 = !{i32 8, !"PIC Level", i32 2}
58+
!22 = !{i32 7, !"PIE Level", i32 2}
59+
!23 = !{i32 7, !"uwtable", i32 2}
60+
!24 = !{i32 7, !"frame-pointer", i32 2}
61+
!25 = !DILocalVariable(name: "buffer", scope: !26, file: !1, line: 30, type: !32)
62+
!26 = distinct !DILexicalBlock(scope: !27, file: !1, line: 29, column: 3)
63+
!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)
64+
!28 = !DISubroutineType(types: !29)
65+
!29 = !{null}
66+
!30 = !{!25, !31, !36, !37}
67+
!31 = !DILocalVariable(name: "buffer2", scope: !27, file: !1, line: 33, type: !32)
68+
!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 640, elements: !34)
69+
!33 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
70+
!34 = !{!35}
71+
!35 = !DISubrange(count: 80)
72+
!36 = !DILocalVariable(name: "a", scope: !27, file: !1, line: 34, type: !11)
73+
!37 = !DILocalVariable(name: "b", scope: !27, file: !1, line: 35, type: !38)
74+
!38 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed)
75+
!39 = !DILocation(line: 30, column: 10, scope: !26)
76+
!40 = !DILocation(line: 33, column: 8, scope: !27)

‎llvm/test/DebugInfo/Generic/discriminated-union.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
; CHECK: DW_AT_alignment
2626
; CHECK: DW_AT_data_member_location [DW_FORM_data1] (0x00)
2727

28-
%F = type { [0 x i8], ptr, [8 x i8] }
28+
%F = type { [0 x i8], i64, [8 x i8] }
2929
%"F::Nope" = type {}
3030

3131
define internal void @_ZN2e34main17h934ff72f9a38d4bbE() unnamed_addr #0 !dbg !5 {
3232
start:
3333
%qq = alloca %F, align 8
3434
call void @llvm.dbg.declare(metadata ptr %qq, metadata !10, metadata !28), !dbg !29
35-
store ptr null, ptr %qq, !dbg !29
35+
store i64 0, ptr %qq, !dbg !29
3636
ret void, !dbg !30
3737
}
3838

‎llvm/test/DebugInfo/Generic/dwarf-public-names.ll

Lines changed: 0 additions & 137 deletions
This file was deleted.

‎llvm/test/DebugInfo/Generic/univariant-discriminated-union.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
; CHECK: DW_AT_alignment
1313
; CHECK: DW_AT_data_member_location [DW_FORM_data1] (0x00)
1414

15-
%F = type { [0 x i8], ptr, [8 x i8] }
15+
%F = type { [0 x i8], i64, [8 x i8] }
1616
%"F::Nope" = type {}
1717

1818
define internal void @_ZN2e34main17h934ff72f9a38d4bbE() unnamed_addr #0 !dbg !5 {
1919
start:
2020
%qq = alloca %F, align 8
2121
call void @llvm.dbg.declare(metadata ptr %qq, metadata !10, metadata !28), !dbg !29
22-
store ptr null, ptr %qq, !dbg !29
22+
store i64 0, ptr %qq, !dbg !29
2323
ret void, !dbg !30
2424
}
2525

‎llvm/test/DebugInfo/Generic/PR20038.ll renamed to ‎llvm/test/DebugInfo/X86/PR20038.ll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
; For some reason, the output when targetting sparc is not quite as expected.
2-
; XFAIL: target=sparc{{.*}}
3-
4-
; RUN: %llc_dwarf -O0 -filetype=obj -dwarf-linkage-names=All < %s | llvm-dwarfdump -debug-info - | FileCheck %s --implicit-check-not=DW_TAG
1+
; 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
52

63
; IR generated from clang -O0 with:
74
; struct C {

‎llvm/test/DebugInfo/X86/fi-piece.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
; CHECK: DW_TAG_subprogram
66
; CHECK: DW_AT_abstract_origin
77
; CHECK: DW_TAG_variable
8-
; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_fbreg -4, DW_OP_piece 0x2, DW_OP_fbreg -8, DW_OP_piece 0x2)
8+
; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_fbreg -8, DW_OP_piece 0x2, DW_OP_fbreg -12, DW_OP_piece 0x2)
99
; CHECK-NEXT: DW_AT_abstract_origin {{.*}}"a"
1010
; Inlined variable, not to be merged.
1111
; CHECK-NOT: DW_TAG
@@ -25,10 +25,11 @@ define void @f() #0 !dbg !8 {
2525
entry:
2626
%a = alloca i16, align 4
2727
%b = alloca i16, align 4
28+
%c = alloca { i16, i16 }, align 4
2829
call void @llvm.dbg.declare(metadata ptr %a, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 16)), !dbg !14
2930
store i16 1, ptr %a, align 4, !dbg !14
3031
call void @llvm.dbg.declare(metadata ptr %b, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 16, 16)), !dbg !16
31-
call void @llvm.dbg.declare(metadata ptr %a, metadata !11, metadata !13), !dbg !17
32+
call void @llvm.dbg.declare(metadata ptr %c, metadata !11, metadata !13), !dbg !17
3233
store i16 2, ptr %b, align 4, !dbg !17
3334
ret void
3435
}

‎llvm/test/DebugInfo/Generic/member-order.ll renamed to ‎llvm/test/DebugInfo/X86/member-order.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: %llc_dwarf -filetype=obj -O0 < %s | llvm-dwarfdump -debug-info - | FileCheck %s
1+
; RUN: %llc_dwarf -mtriple=x86_64-unknown-linux -filetype=obj -O0 < %s | llvm-dwarfdump -debug-info - | FileCheck %s
22

33
; generated by clang from:
44
; struct foo {

‎llvm/test/DebugInfo/Generic/tu-composite.ll renamed to ‎llvm/test/DebugInfo/X86/tu-composite.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: %llc_dwarf -filetype=obj -O0 < %s > %t
1+
; RUN: %llc_dwarf -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s > %t
22
; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s
33
; CHECK: [[TYPE:.*]]: DW_TAG_structure_type
44
; Make sure we correctly handle containing type of a struct being a type identifier.

‎llvm/test/DebugInfo/invalid-sizes.ll

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
; RUN: llvm-as -disable-output < %s 2>&1 | FileCheck %s
2+
3+
; CHECK: llvm.dbg.declare has larger fragment size than alloca size
4+
; CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %slice.dbg.spill, metadata !23, metadata !DIExpression())
5+
; CHECK: llvm.dbg.declare has larger fragment size than alloca size
6+
; CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %slice.dbg.spill1, metadata !23, metadata !DIExpression())
7+
8+
%"EndianSlice<'_>" = type { { ptr, i64 }, i32, [1 x i32] }
9+
10+
; example::test
11+
; Function Attrs: nonlazybind uwtable
12+
define void @_ZN7example4test17h64a501af0fe536ddE(ptr align 1 %s.0, i64 %s.1) unnamed_addr #0 !dbg !7 {
13+
start:
14+
%slice.dbg.spill1 = alloca i32, align 4
15+
%slice.dbg.spill = alloca { ptr, i64 }, align 8
16+
%s.dbg.spill = alloca { ptr, i64 }, align 8
17+
%_2 = alloca %"EndianSlice<'_>", align 8
18+
%0 = getelementptr inbounds { ptr, i64 }, ptr %s.dbg.spill, i32 0, i32 0
19+
store ptr %s.0, ptr %0, align 8
20+
%1 = getelementptr inbounds { ptr, i64 }, ptr %s.dbg.spill, i32 0, i32 1
21+
store i64 %s.1, ptr %1, align 8
22+
call void @llvm.dbg.declare(metadata ptr %s.dbg.spill, metadata !22, metadata !DIExpression()), !dbg !33
23+
%2 = getelementptr inbounds { ptr, i64 }, ptr %slice.dbg.spill, i32 0, i32 0, !dbg !34
24+
store ptr %s.0, ptr %2, align 8, !dbg !34
25+
%3 = getelementptr inbounds { ptr, i64 }, ptr %slice.dbg.spill, i32 0, i32 1, !dbg !34
26+
store i64 %s.1, ptr %3, align 8, !dbg !34
27+
call void @llvm.dbg.declare(metadata ptr %slice.dbg.spill, metadata !23, metadata !DIExpression()), !dbg !35
28+
store i32 1, ptr %slice.dbg.spill1, align 4, !dbg !34
29+
call void @llvm.dbg.declare(metadata ptr %slice.dbg.spill1, metadata !23, metadata !DIExpression()), !dbg !35
30+
ret void, !dbg !36
31+
}
32+
33+
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
34+
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
35+
36+
attributes #0 = { nonlazybind uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
37+
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
38+
39+
!llvm.module.flags = !{!0, !1, !2, !3}
40+
!llvm.ident = !{!4}
41+
!llvm.dbg.cu = !{!5}
42+
43+
!0 = !{i32 8, !"PIC Level", i32 2}
44+
!1 = !{i32 2, !"RtLibUseGOT", i32 1}
45+
!2 = !{i32 2, !"Dwarf Version", i32 4}
46+
!3 = !{i32 2, !"Debug Info Version", i32 3}
47+
!4 = !{!"rustc version 1.74.0-nightly (5c6a7e71c 2023-08-20)"}
48+
!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)
49+
!6 = !DIFile(filename: "/app/example.rs/@/example.a6c375ed18e8f6d3-cgu.0", directory: "/app")
50+
!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)
51+
!8 = !DIFile(filename: "example.rs", directory: "/app", checksumkind: CSK_MD5, checksum: "bd53c9e80c244adbeae5aa0d57de599d")
52+
!9 = !DINamespace(name: "example", scope: null)
53+
!10 = !DISubroutineType(types: !11)
54+
!11 = !{null, !12}
55+
!12 = !DICompositeType(tag: DW_TAG_structure_type, name: "&[u8]", file: !13, size: 128, align: 64, elements: !14, templateParams: !20, identifier: "4f7d759e2003ffb713a77bd933fd0146")
56+
!13 = !DIFile(filename: "<unknown>", directory: "")
57+
!14 = !{!15, !18}
58+
!15 = !DIDerivedType(tag: DW_TAG_member, name: "data_ptr", scope: !12, file: !13, baseType: !16, size: 64, align: 64)
59+
!16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !17, size: 64, align: 64, dwarfAddressSpace: 0)
60+
!17 = !DIBasicType(name: "u8", size: 8, encoding: DW_ATE_unsigned)
61+
!18 = !DIDerivedType(tag: DW_TAG_member, name: "length", scope: !12, file: !13, baseType: !19, size: 64, align: 64, offset: 64)
62+
!19 = !DIBasicType(name: "usize", size: 64, encoding: DW_ATE_unsigned)
63+
!20 = !{}
64+
!21 = !{!22, !23}
65+
!22 = !DILocalVariable(name: "s", arg: 1, scope: !7, file: !8, line: 9, type: !12)
66+
!23 = !DILocalVariable(name: "slice", scope: !24, file: !8, line: 10, type: !25, align: 8)
67+
!24 = distinct !DILexicalBlock(scope: !7, file: !8, line: 10, column: 5)
68+
!25 = !DICompositeType(tag: DW_TAG_structure_type, name: "EndianSlice", scope: !9, file: !13, size: 192, align: 64, elements: !26, templateParams: !20, identifier: "f1b6e593370159e9df4228aa26ace4b5")
69+
!26 = !{!27, !28}
70+
!27 = !DIDerivedType(tag: DW_TAG_member, name: "slice", scope: !25, file: !13, baseType: !12, size: 128, align: 64)
71+
!28 = !DIDerivedType(tag: DW_TAG_member, name: "endian", scope: !25, file: !13, baseType: !29, size: 32, align: 32, offset: 128)
72+
!29 = !DICompositeType(tag: DW_TAG_structure_type, name: "Endian", scope: !9, file: !13, size: 32, align: 32, elements: !30, templateParams: !20, identifier: "a76092aada82685a5b963f3da7ae1bd9")
73+
!30 = !{!31}
74+
!31 = !DIDerivedType(tag: DW_TAG_member, name: "__0", scope: !29, file: !13, baseType: !32, size: 32, align: 32)
75+
!32 = !DIBasicType(name: "i32", size: 32, encoding: DW_ATE_signed)
76+
!33 = !DILocation(line: 9, column: 13, scope: !7)
77+
!34 = !DILocation(line: 10, column: 17, scope: !7)
78+
!35 = !DILocation(line: 10, column: 9, scope: !24)
79+
!36 = !DILocation(line: 11, column: 2, scope: !37)
80+
!37 = !DILexicalBlockFile(scope: !7, file: !8, discriminator: 0)

‎llvm/test/Linker/type-unique-odr-a.ll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; REQUIRES: object-emission
1+
; REQUIRES: x86-registered-target
22
;
33
; RUN: llvm-link %s %p/type-unique-odr-b.ll -S -o - \
44
; RUN: | %llc_dwarf -dwarf-linkage-names=All -filetype=obj -O0 \
@@ -56,6 +56,8 @@
5656

5757
; ModuleID = 'type-unique-odr-a.cpp'
5858

59+
target triple = "x86_64-unknown-linux-gnu"
60+
5961
%class.A = type { i32 }
6062

6163
; Function Attrs: nounwind

‎llvm/test/Linker/type-unique-odr-b.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
; ModuleID = 'type-unique-odr-b.cpp'
2121

22+
target triple = "x86_64-unknown-linux-gnu"
23+
2224
%class.A = type { i32 }
2325

2426
; Function Attrs: nounwind

‎llvm/test/Linker/type-unique-simple2-a.ll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; REQUIRES: object-emission
1+
; REQUIRES: x86-registered-target
22
;
33
; RUN: llvm-link %s %p/type-unique-simple2-b.ll -S -o - | %llc_dwarf -filetype=obj -O0 | llvm-dwarfdump -v -debug-info - | FileCheck %s
44
;
@@ -26,6 +26,8 @@
2626

2727
; ModuleID = 'a.cpp'
2828

29+
target triple = "x86_64-unknown-linux-gnu"
30+
2931
%class.A = type { ptr }
3032

3133
@_ZTV1A = external unnamed_addr constant [4 x ptr]

‎llvm/test/Linker/type-unique-simple2-b.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
; target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
1111
; target triple = "x86_64-apple-macosx10.9.0"
1212

13+
target triple = "x86_64-unknown-linux-gnu"
14+
1315
%class.A = type { ptr }
1416

1517
@_ZTV1A = unnamed_addr constant [4 x ptr] [ptr null, ptr @_ZTI1A, ptr @_ZN1A6setFooEv, ptr @_ZN1A6getFooEv]

‎llvm/test/Transforms/InstCombine/dbg-scalable-store-fixed-frag.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
define i32 @foo(<vscale x 2 x i32> %x) {
55
; CHECK-LABEL: @foo(
66
; CHECK-NEXT: entry:
7-
; CHECK-NEXT: [[ARR:%.*]] = alloca i32, align 8
8-
; CHECK-NEXT: call void @llvm.dbg.value(metadata <vscale x 2 x i32> undef, metadata [[META8:![0-9]+]], metadata !DIExpression()), !dbg [[DBG14:![0-9]+]]
7+
; CHECK-NEXT: [[ARR:%.*]] = alloca [4 x i32], align 8
8+
; CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr [[ARR]], metadata [[META8:![0-9]+]], metadata !DIExpression()), !dbg [[DBG14:![0-9]+]]
99
; CHECK-NEXT: store <vscale x 2 x i32> [[X:%.*]], ptr [[ARR]], align 8
1010
; CHECK-NEXT: [[RES:%.*]] = load i32, ptr [[ARR]], align 8
1111
; CHECK-NEXT: ret i32 [[RES]]
1212
;
1313
entry:
14-
%arr = alloca i32, align 4
14+
%arr = alloca [4 x i32], align 4
1515
call void @llvm.dbg.declare(metadata ptr %arr, metadata !8, metadata !DIExpression()), !dbg !14
1616
store <vscale x 2 x i32> %x, ptr %arr, align 4
1717
%res = load i32, ptr %arr

‎llvm/test/Transforms/InstCombine/dbg-simplify-alloca-size.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata)
77

88
; CHECK-LABEL: @toplevel(
99
; CHECK: entry:
10-
; CHECK-NEXT: %pixels1 = alloca [3 x i8], align 1
10+
; CHECK-NEXT: %pixels1 = alloca [4 x i8], align 1
1111
; CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %pixels1, metadata ![[MD:[0-9]+]], metadata !DIExpression()), !dbg ![[DBG:[0-9]+]]
1212
; CHECK-NEXT: call void @foo(ptr nonnull %pixels1)
1313
; CHECK-NEXT: ret void
1414
define dso_local void @toplevel() {
1515
entry:
16-
%pixels = alloca i8, i32 3
16+
%pixels = alloca i8, i32 4
1717
call void @llvm.dbg.declare(metadata ptr %pixels, metadata !11, metadata !DIExpression()), !dbg !12
1818
call void @foo(ptr %pixels)
1919
ret void

‎llvm/test/Transforms/Util/dbg-user-of-aext.ll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
; opposed to the operand of a [s|z]ext).
44
; RUN: opt -S -passes='sroa' %s | FileCheck %s
55

6+
target datalayout = "i64:64"
7+
68
; Built from:
79
; struct foo { bool b; long i; };
810
; void f(bool b, bool expr, foo g) {
@@ -12,15 +14,15 @@
1214

1315
; Expect two fragments:
1416
; * first starting at bit 0, 8 bits (for the bool)
15-
; * second starting at bit 32, 32 bits (for the long)
16-
; (this happens to create/demonstrate a gap from bits [7, 32))
17+
; * second starting at bit 64, 64 bits (for the long)
18+
; (this happens to create/demonstrate a gap from bits [7, 64))
1719

1820
; But also check that a complex expression is not used for a lone bool
1921
; parameter. It can reference the register it's in directly without masking off
2022
; high bits or anything
2123

2224
; CHECK: call void @llvm.dbg.value(metadata i8 %g.coerce0, metadata ![[VAR_STRUCT:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 8))
23-
; CHECK: call void @llvm.dbg.value(metadata i64 %g.coerce1, metadata ![[VAR_STRUCT]], metadata !DIExpression(DW_OP_LLVM_fragment, 32, 64))
25+
; CHECK: call void @llvm.dbg.value(metadata i64 %g.coerce1, metadata ![[VAR_STRUCT]], metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64))
2426
; CHECK: call void @llvm.dbg.value(metadata i8 %frombool, metadata ![[VAR_BOOL:[0-9]+]], metadata !DIExpression())
2527
; CHECK: call void @llvm.dbg.value(metadata i8 %frombool1, metadata ![[VAR_FRAG:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 4))
2628

0 commit comments

Comments
 (0)
Please sign in to comment.