xref: /llvm-project/llvm/test/Transforms/GlobalOpt/localize-constexpr-debuginfo.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; RUN: opt -S < %s -passes=globalopt --experimental-debuginfo-iterators=false | FileCheck %s
2;; FIXME: this test is pinned to not use RemoveDIs non-intrinsic debug-info.
3;; Constant-deletion takes a slightly different path and (correctly) replaces
4;; the operand of the debug-info record with poison instead of a null pointer.
5;; This is a spurious test difference that we'll suppress for turning RemoveDIs
6;; on.
7
8target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
9target triple = "x86_64-unknown-linux-gnu"
10
11@_ZL1x = internal global ptr null, align 8, !dbg !0
12
13define i32 @main(i32 %argc, ptr %argv) norecurse !dbg !18 {
14; CHECK: define i32 @main
15; Make sure we localized the global.
16; CHECK: alloca ptr
17; Make sure the metadata is sane. Currently, we just drop the metadata,
18; so it points to nothing.
19; CHECK: #dbg_value(!2,
20; CHECK: !2 = !{}
21entry:
22  call void @llvm.dbg.value(metadata i32 %argc, metadata !22, metadata !23), !dbg !24
23  call void @llvm.dbg.value(metadata ptr %argv, metadata !25, metadata !23), !dbg !26
24  %0 = load ptr, ptr %argv, align 8, !dbg !27
25  store ptr %0, ptr @_ZL1x, align 8, !dbg !29
26  call void @llvm.dbg.value(metadata ptr @_ZL1x, metadata !30, metadata !23), !dbg !31
27  %1 = load ptr, ptr @_ZL1x, align 8, !dbg !32
28  %2 = load i8, ptr %1, align 1, !dbg !33
29  %conv = sext i8 %2 to i32, !dbg !33
30  ret i32 %conv, !dbg !34
31}
32
33declare void @llvm.dbg.value(metadata, metadata, metadata)
34
35!llvm.dbg.cu = !{!2}
36!llvm.module.flags = !{!15, !16}
37!llvm.ident = !{!17}
38
39!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
40!1 = distinct !DIGlobalVariable(name: "x", linkageName: "_ZL1x", scope: !2, file: !14, line: 1, type: !6, isLocal: true, isDefinition: true)
41!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !5, globals: !13)
42!3 = !DIFile(filename: "-", directory: "/")
43!4 = !{}
44!5 = !{!6, !11}
45!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)
46!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 1600, elements: !9)
47!8 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
48!9 = !{!10}
49!10 = !DISubrange(count: 200)
50!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
51!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64)
52!13 = !{!0}
53!14 = !DIFile(filename: "<stdin>", directory: "/")
54!15 = !{i32 2, !"Dwarf Version", i32 4}
55!16 = !{i32 2, !"Debug Info Version", i32 3}
56!17 = !{!"clang"}
57!18 = distinct !DISubprogram(name: "main", scope: !14, file: !14, line: 2, type: !19, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4)
58!19 = !DISubroutineType(types: !20)
59!20 = !{!21, !21, !11}
60!21 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
61!22 = !DILocalVariable(name: "argc", arg: 1, scope: !18, file: !14, line: 2, type: !21)
62!23 = !DIExpression()
63!24 = !DILocation(line: 2, column: 14, scope: !18)
64!25 = !DILocalVariable(name: "argv", arg: 2, scope: !18, file: !14, line: 2, type: !11)
65!26 = !DILocation(line: 2, column: 26, scope: !18)
66!27 = !DILocation(line: 2, column: 52, scope: !18)
67!28 = !DILocation(line: 2, column: 38, scope: !18)
68!29 = !DILocation(line: 2, column: 36, scope: !18)
69!30 = !DILocalVariable(name: "y", scope: !18, file: !14, line: 2, type: !11)
70!31 = !DILocation(line: 2, column: 68, scope: !18)
71!32 = !DILocation(line: 2, column: 92, scope: !18)
72!33 = !DILocation(line: 2, column: 91, scope: !18)
73!34 = !DILocation(line: 2, column: 84, scope: !18)
74