1; REQUIRES: x86-registered-target 2; RUN: llc -filetype=obj %s -o %t 3; RUN: llvm-profgen --binary=%t --perfscript=%s --output=%t1 --show-disassembly -x86-asm-syntax=intel --show-source-locations | FileCheck %s --match-full-lines 4 5; CHECK: Disassembly of section .text [0x0, 0x4a]: 6; CHECK: <funcA>: 7; CHECK: 0: mov eax, edi funcA:0 8; CHECK: 2: mov ecx, dword ptr [rip] funcLeaf:2 @ funcA:1 9; CHECK: 8: lea edx, [rcx + 3] fib:2 @ funcLeaf:2 @ funcA:1 10; CHECK: b: cmp ecx, 3 fib:2 @ funcLeaf:2 @ funcA:1 11; CHECK: e: cmovl edx, ecx fib:2 @ funcLeaf:2 @ funcA:1 12; CHECK: 11: sub eax, edx funcLeaf:2 @ funcA:1 13; CHECK: 13: ret funcA:2 14; CHECK: 14: nop word ptr cs:[rax + rax] 15; CHECK: 1e: nop 16; CHECK: <funcLeaf>: 17; CHECK: 20: mov eax, edi funcLeaf:1 18; CHECK: 22: mov ecx, dword ptr [rip] funcLeaf:2 19; CHECK: 28: lea edx, [rcx + 3] fib:2 @ funcLeaf:2 20; CHECK: 2b: cmp ecx, 3 fib:2 @ funcLeaf:2 21; CHECK: 2e: cmovl edx, ecx fib:2 @ funcLeaf:2 22; CHECK: 31: sub eax, edx funcLeaf:2 23; CHECK: 33: ret funcLeaf:3 24; CHECK: 34: nop word ptr cs:[rax + rax] 25; CHECK: 3e: nop 26; CHECK: <fib>: 27; CHECK: 40: lea eax, [rdi + 3] fib:2 28; CHECK: 43: cmp edi, 3 fib:2 29; CHECK: 46: cmovl eax, edi fib:2 30; CHECK: 49: ret fib:8 31 32target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 33target triple = "x86_64-unknown-linux-gnu" 34 35@factor = dso_local global i32 3 36 37define dso_local i32 @funcA(i32 %x) !dbg !12 { 38entry: 39 call void @llvm.dbg.value(metadata i32 %x, metadata !16, metadata !DIExpression()), !dbg !18 40 call void @llvm.dbg.value(metadata i32 %x, metadata !19, metadata !DIExpression()), !dbg !22 41 %0 = load volatile i32, i32* @factor, align 4, !dbg !24, !tbaa !25 42 call void @llvm.dbg.value(metadata i32 %0, metadata !29, metadata !DIExpression()), !dbg !32 43 %cmp.i.i = icmp slt i32 %0, 3, !dbg !34 44 %add.i.i = add nsw i32 %0, 3, !dbg !36 45 %retval.0.i.i = select i1 %cmp.i.i, i32 %0, i32 %add.i.i, !dbg !36 46 %sub.i = sub nsw i32 %x, %retval.0.i.i, !dbg !37 47 call void @llvm.dbg.value(metadata i32 %sub.i, metadata !19, metadata !DIExpression()), !dbg !22 48 call void @llvm.dbg.value(metadata i32 %sub.i, metadata !17, metadata !DIExpression()), !dbg !18 49 ret i32 %sub.i, !dbg !38 50} 51 52define dso_local i32 @funcLeaf(i32 %x) !dbg !20 { 53entry: 54 call void @llvm.dbg.value(metadata i32 %x, metadata !19, metadata !DIExpression()), !dbg !39 55 %0 = load volatile i32, i32* @factor, align 4, !dbg !40, !tbaa !25 56 call void @llvm.dbg.value(metadata i32 %0, metadata !29, metadata !DIExpression()), !dbg !41 57 %cmp.i = icmp slt i32 %0, 3, !dbg !43 58 %add.i = add nsw i32 %0, 3, !dbg !44 59 %retval.0.i = select i1 %cmp.i, i32 %0, i32 %add.i, !dbg !44 60 %sub = sub nsw i32 %x, %retval.0.i, !dbg !45 61 call void @llvm.dbg.value(metadata i32 %sub, metadata !19, metadata !DIExpression()), !dbg !39 62 ret i32 %sub, !dbg !46 63} 64 65define dso_local i32 @fib(i32 %x) !dbg !30 { 66entry: 67 call void @llvm.dbg.value(metadata i32 %x, metadata !29, metadata !DIExpression()), !dbg !47 68 %cmp = icmp slt i32 %x, 3, !dbg !48 69 %add = add nsw i32 %x, 3, !dbg !49 70 %retval.0 = select i1 %cmp, i32 %x, i32 %add, !dbg !49 71 ret i32 %retval.0, !dbg !50 72} 73 74declare void @llvm.dbg.value(metadata, metadata, metadata) #2 75 76!llvm.dbg.cu = !{!2} 77!llvm.module.flags = !{!8, !9, !10} 78 79!1 = distinct !DIGlobalVariable(name: "factor", scope: !2, file: !3, line: 3, type: !6, isLocal: false, isDefinition: true) 80!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, emissionKind: FullDebug) 81!3 = !DIFile(filename: "test.c", directory: "test") 82!4 = !{} 83!6 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !7) 84!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 85!8 = !{i32 7, !"Dwarf Version", i32 4} 86!9 = !{i32 2, !"Debug Info Version", i32 3} 87!10 = !{i32 1, !"wchar_size", i32 4} 88!12 = distinct !DISubprogram(name: "funcA", scope: !3, file: !3, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !15) 89!13 = !DISubroutineType(types: !14) 90!14 = !{!7, !7} 91!15 = !{!16, !17} 92!16 = !DILocalVariable(name: "x", arg: 1, scope: !12, file: !3, line: 6, type: !7) 93!17 = !DILocalVariable(name: "r", scope: !12, file: !3, line: 7, type: !7) 94!18 = !DILocation(line: 0, scope: !12) 95!19 = !DILocalVariable(name: "x", arg: 1, scope: !20, file: !3, line: 22, type: !7) 96!20 = distinct !DISubprogram(name: "funcLeaf", scope: !3, file: !3, line: 22, type: !13, scopeLine: 23, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !21) 97!21 = !{!19} 98!22 = !DILocation(line: 0, scope: !20, inlinedAt: !23) 99!23 = distinct !DILocation(line: 7, column: 11, scope: !12) 100!24 = !DILocation(line: 24, column: 12, scope: !20, inlinedAt: !23) 101!25 = !{!26, !26, i64 0} 102!26 = !{!"int", !27, i64 0} 103!27 = !{!"omnipotent char", !28, i64 0} 104!28 = !{!"Simple C/C++ TBAA"} 105!29 = !DILocalVariable(name: "x", arg: 1, scope: !30, file: !3, line: 11, type: !7) 106!30 = distinct !DISubprogram(name: "fib", scope: !3, file: !3, line: 11, type: !13, scopeLine: 12, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !31) 107!31 = !{!29} 108!32 = !DILocation(line: 0, scope: !30, inlinedAt: !33) 109!33 = distinct !DILocation(line: 24, column: 8, scope: !20, inlinedAt: !23) 110!34 = !DILocation(line: 13, column: 9, scope: !35, inlinedAt: !33) 111!35 = distinct !DILexicalBlock(scope: !30, file: !3, line: 13, column: 7) 112!36 = !DILocation(line: 13, column: 7, scope: !30, inlinedAt: !33) 113!37 = !DILocation(line: 24, column: 5, scope: !20, inlinedAt: !23) 114!38 = !DILocation(line: 8, column: 3, scope: !12) 115!39 = !DILocation(line: 0, scope: !20) 116!40 = !DILocation(line: 24, column: 12, scope: !20) 117!41 = !DILocation(line: 0, scope: !30, inlinedAt: !42) 118!42 = distinct !DILocation(line: 24, column: 8, scope: !20) 119!43 = !DILocation(line: 13, column: 9, scope: !35, inlinedAt: !42) 120!44 = !DILocation(line: 13, column: 7, scope: !30, inlinedAt: !42) 121!45 = !DILocation(line: 24, column: 5, scope: !20) 122!46 = !DILocation(line: 25, column: 3, scope: !20) 123!47 = !DILocation(line: 0, scope: !30) 124!48 = !DILocation(line: 13, column: 9, scope: !35) 125!49 = !DILocation(line: 13, column: 7, scope: !30) 126!50 = !DILocation(line: 19, column: 1, scope: !30) 127