64 lines · plain
1; RUN: opt -S %s -o - --passes=declare-to-assign \2; RUN: | FileCheck %s --implicit-check-not="#dbg_"3 4;; Assignment tracking doesn't add any value when optimisations are disabled.5;; Check it doesn't get applied to functions marked optnone.6 7; CHECK: @_Z3funv8; CHECK: #dbg_assign9 10; CHECK: @_Z3funv211; CHECK: #dbg_declare12 13define dso_local void @_Z3funv() local_unnamed_addr !dbg !16 {14entry:15 %a = alloca i3216 call void @llvm.dbg.declare(metadata ptr %a, metadata !20, metadata !DIExpression()), !dbg !2517 ret void18}19 20; Function Attrs: noinline optnone21define dso_local void @_Z3funv2() local_unnamed_addr #1 !dbg !39 {22entry:23 %a = alloca i3224 call void @llvm.dbg.declare(metadata ptr %a, metadata !41, metadata !DIExpression()), !dbg !4425 ret void26}27 28attributes #1 = {noinline optnone}29 30declare void @llvm.dbg.declare(metadata, metadata, metadata)31 32!llvm.dbg.cu = !{!2}33!llvm.module.flags = !{!8, !9, !10, !11, !12, !13}34!llvm.ident = !{!15}35 36!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())37!1 = distinct !DIGlobalVariable(name: "G", scope: !2, file: !3, line: 1, type: !7, isLocal: false, isDefinition: true)38!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)39!3 = !DIFile(filename: "test.cpp", directory: "/")40!4 = !{!0, !5}41!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())42!6 = distinct !DIGlobalVariable(name: "F", scope: !2, file: !3, line: 1, type: !7, isLocal: false, isDefinition: true)43!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)44!8 = !{i32 7, !"Dwarf Version", i32 5}45!9 = !{i32 2, !"Debug Info Version", i32 3}46!10 = !{i32 1, !"wchar_size", i32 4}47!11 = !{i32 8, !"PIC Level", i32 2}48!12 = !{i32 7, !"PIE Level", i32 2}49!13 = !{i32 7, !"uwtable", i32 2}50!15 = !{!"clang version 17.0.0"}51!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)52!17 = !DISubroutineType(types: !18)53!18 = !{null}54!19 = !{!20}55!20 = !DILocalVariable(name: "X", scope: !16, file: !3, line: 4, type: !21)56!21 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)57!22 = !{}58!25 = !DILocation(line: 0, scope: !16)59!27 = distinct !DILexicalBlock(scope: !16, file: !3, line: 7, column: 7)60!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)61!40 = !{!41}62!41 = !DILocalVariable(name: "X", scope: !39, file: !3, line: 10, type: !21)63!44 = !DILocation(line: 0, scope: !39)64