1; RUN: opt -hotcoldsplit -hotcoldsplit-threshold=0 -S < %s | FileCheck %s 2 3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 4target triple = "x86_64-apple-macosx10.14.0" 5 6; The block "if.end" in @foo is extracted into a new function, @foo.cold.1. 7; Check the following: 8 9; CHECK-LABEL: define {{.*}}@foo.cold.1 10 11; - The llvm.dbg.value intrinsic pointing to an argument in @foo (%arg1) is 12; dropped 13; CHECK-NOT: llvm.dbg.value 14 15; - Instructions without locations in the original function have no 16; location in the new function 17; CHECK: [[ADD1:%.*]] = add i32 %{{.*}}, 1{{$}} 18 19; - Ditto (see above), calls are not special 20; CHECK-NEXT: call void @sink(i32 [[ADD1]]) 21 22; - Line locations are preserved 23; CHECK-NEXT: call void @sink(i32 [[ADD1]]), !dbg [[LINE1:![0-9]+]] 24 25; - llvm.dbg.value intrinsics for values local to @foo.cold.1 are preserved 26; CHECK-NEXT: llvm.dbg.value(metadata i32 [[ADD1]], metadata [[VAR1:![0-9]+]], metadata !DIExpression()), !dbg [[LINE1]] 27 28; - Expressions inside of dbg.value intrinsics are preserved 29; CHECK-NEXT: llvm.dbg.value(metadata i32 [[ADD1]], metadata [[VAR1]], metadata !DIExpression(DW_OP_constu, 1, DW_OP_plus, DW_OP_stack_value) 30 31; - The DISubprogram for @foo.cold.1 has an empty DISubroutineType 32; CHECK: [[FILE:![0-9]+]] = !DIFile(filename: "<stdin>" 33; CHECK: [[EMPTY_MD:![0-9]+]] = !{} 34; CHECK: [[EMPTY_TYPE:![0-9]+]] = !DISubroutineType(types: [[EMPTY_MD]]) 35; CHECK: [[NEWSCOPE:![0-9]+]] = distinct !DISubprogram(name: "foo.cold.1", linkageName: "foo.cold.1", scope: null, file: [[FILE]], type: [[EMPTY_TYPE]], spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized 36 37; - Line locations in @foo.cold.1 point to the new scope for @foo.cold.1 38; CHECK: [[LINE1]] = !DILocation(line: 1, column: 1, scope: [[NEWSCOPE]]) 39 40define void @foo(i32 %arg1) !dbg !6 { 41entry: 42 %var = add i32 0, 0, !dbg !11 43 br i1 undef, label %if.then, label %if.end 44 45if.then: ; preds = %entry 46 ret void 47 48if.end: ; preds = %entry 49 call void @llvm.dbg.value(metadata i32 %arg1, metadata !9, metadata !DIExpression()), !dbg !11 50 %add1 = add i32 %arg1, 1 51 call void @sink(i32 %add1) 52 call void @sink(i32 %add1), !dbg !11 53 call void @llvm.dbg.value(metadata i32 %add1, metadata !9, metadata !DIExpression()), !dbg !11 54 call void @llvm.dbg.value(metadata i32 %add1, metadata !9, metadata !DIExpression(DW_OP_constu, 1, DW_OP_plus, DW_OP_stack_value)), !dbg !11 55 ret void 56} 57 58declare void @llvm.dbg.value(metadata, metadata, metadata) 59 60declare void @sink(i32) cold 61 62!llvm.dbg.cu = !{!0} 63!llvm.debugify = !{!3, !4} 64!llvm.module.flags = !{!5} 65 66!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 67!1 = !DIFile(filename: "<stdin>", directory: "/") 68!2 = !{} 69!3 = !{i32 7} 70!4 = !{i32 1} 71!5 = !{i32 2, !"Debug Info Version", i32 3} 72!6 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0, retainedNodes: !8) 73!7 = !DISubroutineType(types: !2) 74!8 = !{!9} 75!9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10) 76!10 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned) 77!11 = !DILocation(line: 1, column: 1, scope: !6) 78