xref: /llvm-project/llvm/test/DebugInfo/Generic/assignment-tracking/optnone.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; RUN: opt -S %s -o - --passes=declare-to-assign \
2; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
3; RUN: opt --try-experimental-debuginfo-iterators -S %s -o - --passes=declare-to-assign \
4; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
5
6;; Assignment tracking doesn't add any value when optimisations are disabled.
7;; Check it doesn't get applied to functions marked optnone.
8
9; CHECK: @_Z3funv
10; CHECK: #dbg_assign
11
12; CHECK: @_Z3funv2
13; CHECK: #dbg_declare
14
15define dso_local void @_Z3funv() local_unnamed_addr !dbg !16 {
16entry:
17  %a = alloca i32
18  call void @llvm.dbg.declare(metadata ptr %a, metadata !20, metadata !DIExpression()), !dbg !25
19  ret void
20}
21
22; Function Attrs: noinline optnone
23define dso_local void @_Z3funv2() local_unnamed_addr #1 !dbg !39 {
24entry:
25  %a = alloca i32
26  call void @llvm.dbg.declare(metadata ptr %a, metadata !41, metadata !DIExpression()), !dbg !44
27  ret void
28}
29
30attributes #1 = {noinline optnone}
31
32declare void @llvm.dbg.declare(metadata, metadata, metadata)
33
34!llvm.dbg.cu = !{!2}
35!llvm.module.flags = !{!8, !9, !10, !11, !12, !13}
36!llvm.ident = !{!15}
37
38!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
39!1 = distinct !DIGlobalVariable(name: "G", scope: !2, file: !3, line: 1, type: !7, isLocal: false, isDefinition: true)
40!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 17.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
41!3 = !DIFile(filename: "test.cpp", directory: "/")
42!4 = !{!0, !5}
43!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
44!6 = distinct !DIGlobalVariable(name: "F", scope: !2, file: !3, line: 1, type: !7, isLocal: false, isDefinition: true)
45!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
46!8 = !{i32 7, !"Dwarf Version", i32 5}
47!9 = !{i32 2, !"Debug Info Version", i32 3}
48!10 = !{i32 1, !"wchar_size", i32 4}
49!11 = !{i32 8, !"PIC Level", i32 2}
50!12 = !{i32 7, !"PIE Level", i32 2}
51!13 = !{i32 7, !"uwtable", i32 2}
52!15 = !{!"clang version 17.0.0"}
53!16 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !3, file: !3, line: 3, type: !17, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !19)
54!17 = !DISubroutineType(types: !18)
55!18 = !{null}
56!19 = !{!20}
57!20 = !DILocalVariable(name: "X", scope: !16, file: !3, line: 4, type: !21)
58!21 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
59!22 = !{}
60!25 = !DILocation(line: 0, scope: !16)
61!27 = distinct !DILexicalBlock(scope: !16, file: !3, line: 7, column: 7)
62!39 = distinct !DISubprogram(name: "fun2", linkageName: "_Z3funv2", scope: !3, file: !3, line: 3, type: !17, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !40)
63!40 = !{!41}
64!41 = !DILocalVariable(name: "X", scope: !39, file: !3, line: 10, type: !21)
65!44 = !DILocation(line: 0, scope: !39)
66