|
| 1 | +; RUN: split-file %s %t |
| 2 | +; RUN: clang %t/a.ll -o %t/a.out |
| 3 | +; RUN: llvm-profdata merge --debug-info=%t/a.out %t/a.proftext -o %t/a.profdata 2>&1 | FileCheck %s --implicit-check-not=warning |
| 4 | + |
| 5 | +; CHECK: warning: Incomplete DIE for function None: |
| 6 | +; CHECK: warning: Incomplete DIE for function no_cfg: CFGHash=None |
| 7 | +; CHECK: warning: Incomplete DIE for function no_counter: {{.*}} NumCounters=None |
| 8 | +; CHECK: warning: Incomplete DIE for function no_profc: {{.*}} CounterPtr=None |
| 9 | +; CHECK: warning: Could not find address of function no_func |
| 10 | + |
| 11 | +;--- a.proftext |
| 12 | +:ir |
| 13 | + |
| 14 | +;--- a.c |
| 15 | +int main() { return 0; } |
| 16 | + |
| 17 | +void removed() {} |
| 18 | +void no_name() {} |
| 19 | +void no_cfg() {} |
| 20 | +void no_counter() {} |
| 21 | +void no_profc() {} |
| 22 | +void no_func() {} |
| 23 | +;--- gen |
| 24 | +clang --target=x86_64-linux -fprofile-generate -mllvm -debug-info-correlate -S -emit-llvm -g a.c -o - |
| 25 | +# NOTE: After generating the IR below, manually remove the follwing pieces |
| 26 | +# 1. Remove "@removed" function and "@__profc_removed" global |
| 27 | +# 2. Remove "Function Name" annotation for "@no_name" |
| 28 | +# 3. Remove "CFG Hash" annotation for "@no_cfg" |
| 29 | +# 4. Remove "Num Counters" annotation for "@no_counter" |
| 30 | +# 5. Remove "@__profc_no_profc" |
| 31 | +# 6. Remove "@no_func" |
| 32 | +;--- a.ll |
| 33 | +; ModuleID = 'a.c' |
| 34 | +source_filename = "a.c" |
| 35 | +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" |
| 36 | +target triple = "x86_64-unknown-linux" |
| 37 | + |
| 38 | +$__llvm_profile_raw_version = comdat any |
| 39 | + |
| 40 | +$__profc_main = comdat nodeduplicate |
| 41 | + |
| 42 | +$__profc_removed = comdat nodeduplicate |
| 43 | + |
| 44 | +$__profc_no_name = comdat nodeduplicate |
| 45 | + |
| 46 | +$__profc_no_cfg = comdat nodeduplicate |
| 47 | + |
| 48 | +$__profc_no_counter = comdat nodeduplicate |
| 49 | + |
| 50 | +$__profc_no_profc = comdat nodeduplicate |
| 51 | + |
| 52 | +$__profc_no_func = comdat nodeduplicate |
| 53 | + |
| 54 | +$__llvm_profile_filename = comdat any |
| 55 | + |
| 56 | +@__llvm_profile_raw_version = hidden constant i64 648518346341351434, comdat |
| 57 | +@__profn_main = private constant [4 x i8] c"main" |
| 58 | +@__profn_removed = private constant [7 x i8] c"removed" |
| 59 | +@__profn_no_name = private constant [7 x i8] c"no_name" |
| 60 | +@__profn_no_cfg = private constant [6 x i8] c"no_cfg" |
| 61 | +@__profn_no_counter = private constant [10 x i8] c"no_counter" |
| 62 | +@__profn_no_profc = private constant [8 x i8] c"no_profc" |
| 63 | +@__profn_no_func = private constant [7 x i8] c"no_func" |
| 64 | +@__profc_main = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", comdat, align 8, !dbg !0 |
| 65 | +@__profc_no_name = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", comdat, align 8, !dbg !19 |
| 66 | +@__profc_no_cfg = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", comdat, align 8, !dbg !24 |
| 67 | +@__profc_no_counter = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", comdat, align 8, !dbg !29 |
| 68 | +@__profc_no_func = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", comdat, align 8, !dbg !39 |
| 69 | +@llvm.compiler.used = appending global [5 x ptr] [ptr @__profc_main, ptr @__profc_no_name, ptr @__profc_no_cfg, ptr @__profc_no_counter, ptr @__profc_no_func], section "llvm.metadata" |
| 70 | +@__llvm_profile_filename = hidden constant [20 x i8] c"default_%m.proflite\00", comdat |
| 71 | + |
| 72 | +; Function Attrs: noinline nounwind optnone uwtable |
| 73 | +define dso_local i32 @main() #0 !dbg !2 { |
| 74 | + %1 = alloca i32, align 4 |
| 75 | + %2 = load i64, ptr @__profc_main, align 8 |
| 76 | + %3 = add i64 %2, 1 |
| 77 | + store i64 %3, ptr @__profc_main, align 8 |
| 78 | + store i32 0, ptr %1, align 4 |
| 79 | + ret i32 0, !dbg !53 |
| 80 | +} |
| 81 | + |
| 82 | +; Function Attrs: noinline nounwind optnone uwtable |
| 83 | +define dso_local void @no_name() #0 !dbg !21 { |
| 84 | + %1 = load i64, ptr @__profc_no_name, align 8, !dbg !55 |
| 85 | + %2 = add i64 %1, 1, !dbg !55 |
| 86 | + store i64 %2, ptr @__profc_no_name, align 8, !dbg !55 |
| 87 | + ret void, !dbg !55 |
| 88 | +} |
| 89 | + |
| 90 | +; Function Attrs: noinline nounwind optnone uwtable |
| 91 | +define dso_local void @no_cfg() #0 !dbg !26 { |
| 92 | + %1 = load i64, ptr @__profc_no_cfg, align 8, !dbg !56 |
| 93 | + %2 = add i64 %1, 1, !dbg !56 |
| 94 | + store i64 %2, ptr @__profc_no_cfg, align 8, !dbg !56 |
| 95 | + ret void, !dbg !56 |
| 96 | +} |
| 97 | + |
| 98 | +; Function Attrs: noinline nounwind optnone uwtable |
| 99 | +define dso_local void @no_counter() #0 !dbg !31 { |
| 100 | + %1 = load i64, ptr @__profc_no_counter, align 8, !dbg !57 |
| 101 | + %2 = add i64 %1, 1, !dbg !57 |
| 102 | + store i64 %2, ptr @__profc_no_counter, align 8, !dbg !57 |
| 103 | + ret void, !dbg !57 |
| 104 | +} |
| 105 | + |
| 106 | +; Function Attrs: noinline nounwind optnone uwtable |
| 107 | +define dso_local void @no_profc() #0 !dbg !36 { |
| 108 | + ret void, !dbg !58 |
| 109 | +} |
| 110 | + |
| 111 | +; Function Attrs: nounwind |
| 112 | +declare void @llvm.instrprof.increment(ptr, i64, i32, i32) #1 |
| 113 | + |
| 114 | +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } |
| 115 | +attributes #1 = { nounwind } |
| 116 | + |
| 117 | +!llvm.dbg.cu = !{!7} |
| 118 | +!llvm.module.flags = !{!46, !47, !48, !49, !50, !51, !52} |
| 119 | + |
| 120 | +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) |
| 121 | +!1 = distinct !DIGlobalVariable(name: "__profc_main", scope: !2, file: !3, type: !14, isLocal: true, isDefinition: true, annotations: !44) |
| 122 | +!2 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 1, type: !4, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !7) |
| 123 | +!3 = !DIFile(filename: "a.c", directory: "/proc/self/cwd", checksumkind: CSK_MD5, checksum: "22eee0eada6e6964fca794aa5a0966d0") |
| 124 | +!4 = !DISubroutineType(types: !5) |
| 125 | +!5 = !{!6} |
| 126 | +!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| 127 | +!7 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !8, splitDebugInlining: false, nameTableKind: None) |
| 128 | +!8 = !{!0, !9, !19, !24, !29, !34, !39} |
| 129 | +!9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression()) |
| 130 | +!10 = distinct !DIGlobalVariable(name: "__profc_removed", scope: !11, file: !3, type: !14, isLocal: true, isDefinition: true, annotations: !15) |
| 131 | +!11 = distinct !DISubprogram(name: "removed", scope: !3, file: !3, line: 3, type: !12, scopeLine: 3, spFlags: DISPFlagDefinition, unit: !7) |
| 132 | +!12 = !DISubroutineType(types: !13) |
| 133 | +!13 = !{null} |
| 134 | +!14 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "Profile Data Type") |
| 135 | +!15 = !{!16, !17, !18} |
| 136 | +!16 = !{!"Function Name", !"removed"} |
| 137 | +!17 = !{!"CFG Hash", i64 742261418966908927} |
| 138 | +!18 = !{!"Num Counters", i32 1} |
| 139 | +!19 = !DIGlobalVariableExpression(var: !20, expr: !DIExpression()) |
| 140 | +!20 = distinct !DIGlobalVariable(name: "__profc_no_name", scope: !21, file: !3, type: !14, isLocal: true, isDefinition: true, annotations: !22) |
| 141 | +!21 = distinct !DISubprogram(name: "no_name", scope: !3, file: !3, line: 4, type: !12, scopeLine: 4, spFlags: DISPFlagDefinition, unit: !7) |
| 142 | +!22 = !{!17, !18} |
| 143 | +!23 = !{!"Function Name", !"no_name"} |
| 144 | +!24 = !DIGlobalVariableExpression(var: !25, expr: !DIExpression()) |
| 145 | +!25 = distinct !DIGlobalVariable(name: "__profc_no_cfg", scope: !26, file: !3, type: !14, isLocal: true, isDefinition: true, annotations: !27) |
| 146 | +!26 = distinct !DISubprogram(name: "no_cfg", scope: !3, file: !3, line: 5, type: !12, scopeLine: 5, spFlags: DISPFlagDefinition, unit: !7) |
| 147 | +!27 = !{!28, !18} |
| 148 | +!28 = !{!"Function Name", !"no_cfg"} |
| 149 | +!29 = !DIGlobalVariableExpression(var: !30, expr: !DIExpression()) |
| 150 | +!30 = distinct !DIGlobalVariable(name: "__profc_no_counter", scope: !31, file: !3, type: !14, isLocal: true, isDefinition: true, annotations: !32) |
| 151 | +!31 = distinct !DISubprogram(name: "no_counter", scope: !3, file: !3, line: 6, type: !12, scopeLine: 6, spFlags: DISPFlagDefinition, unit: !7) |
| 152 | +!32 = !{!33, !17} |
| 153 | +!33 = !{!"Function Name", !"no_counter"} |
| 154 | +!34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) |
| 155 | +!35 = distinct !DIGlobalVariable(name: "__profc_no_profc", scope: !36, file: !3, type: !14, isLocal: true, isDefinition: true, annotations: !37) |
| 156 | +!36 = distinct !DISubprogram(name: "no_profc", scope: !3, file: !3, line: 7, type: !12, scopeLine: 7, spFlags: DISPFlagDefinition, unit: !7) |
| 157 | +!37 = !{!38, !17, !18} |
| 158 | +!38 = !{!"Function Name", !"no_profc"} |
| 159 | +!39 = !DIGlobalVariableExpression(var: !40, expr: !DIExpression()) |
| 160 | +!40 = distinct !DIGlobalVariable(name: "__profc_no_func", scope: !41, file: !3, type: !14, isLocal: true, isDefinition: true, annotations: !42) |
| 161 | +!41 = distinct !DISubprogram(name: "no_func", scope: !3, file: !3, line: 8, type: !12, scopeLine: 8, spFlags: DISPFlagDefinition, unit: !7) |
| 162 | +!42 = !{!43, !17, !18} |
| 163 | +!43 = !{!"Function Name", !"no_func"} |
| 164 | +!44 = !{!45, !17, !18} |
| 165 | +!45 = !{!"Function Name", !"main"} |
| 166 | +!46 = !{i32 7, !"Dwarf Version", i32 5} |
| 167 | +!47 = !{i32 2, !"Debug Info Version", i32 3} |
| 168 | +!48 = !{i32 1, !"wchar_size", i32 4} |
| 169 | +!49 = !{i32 8, !"PIC Level", i32 2} |
| 170 | +!50 = !{i32 7, !"PIE Level", i32 2} |
| 171 | +!51 = !{i32 7, !"uwtable", i32 2} |
| 172 | +!52 = !{i32 7, !"frame-pointer", i32 2} |
| 173 | +!53 = !DILocation(line: 1, column: 14, scope: !2) |
| 174 | +!54 = !DILocation(line: 3, column: 17, scope: !11) |
| 175 | +!55 = !DILocation(line: 4, column: 17, scope: !21) |
| 176 | +!56 = !DILocation(line: 5, column: 16, scope: !26) |
| 177 | +!57 = !DILocation(line: 6, column: 20, scope: !31) |
| 178 | +!58 = !DILocation(line: 7, column: 18, scope: !36) |
| 179 | +!59 = !DILocation(line: 8, column: 17, scope: !41) |
0 commit comments