1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=generic | FileCheck %s 2 ; Both functions should produce the same code. The presence of debug values 3 ; should not affect the scheduling strategy. 4 ; Generated from: 5 ; char argc; 6 ; class C { 7 ; public: 8 ; int test(char ,char ,char ,...); 9 ; }; 10 ; void foo() { 11 ; C c; 12 ; char lc = argc; 13 ; c.test(0,argc,0,lc); 14 ; c.test(0,argc,0,lc); 15 ; } 16 ; 17 ; with 18 ; clang -O2 -c test.cpp -emit-llvm -S 19 ; clang -O2 -c test.cpp -emit-llvm -S -g 20 ; 21 22 source_filename = "test/CodeGen/X86/misched-code-difference-with-debug.ll" 23 24 %class.C = type { i8 } 25 26 @argc = global i8 0, align 1, !dbg !0 27 28 declare i32 @test_function(%class.C*, i8 signext, i8 signext, i8 signext, ...) 29 ; CHECK-LABEL: test_without_debug 30 ; CHECK: movl [[A:%[a-z]+]], [[B:%[a-z]+]] 31 ; CHECK-NEXT: movl [[A]], [[C:%[a-z]+]] 32 33 define void @test_without_debug() { 34 entry: 35 %c = alloca %class.C, align 1 36 %0 = load i8, i8* @argc, align 1 37 %conv = sext i8 %0 to i32 38 %call = call i32 (%class.C*, i8, i8, i8, ...) @test_function(%class.C* %c, i8 signext 0, i8 signext %0, i8 signext 0, i32 %conv) 39 %1 = load i8, i8* @argc, align 1 40 %call2 = call i32 (%class.C*, i8, i8, i8, ...) @test_function(%class.C* %c, i8 signext 0, i8 signext %1, i8 signext 0, i32 %conv) 41 ret void 42 } 43 ; CHECK-LABEL: test_with_debug 44 ; CHECK: movl [[A]], [[B]] 45 ; CHECK-NEXT: movl [[A]], [[C]] 46 47 define void @test_with_debug() !dbg !17 { 48 entry: 49 %c = alloca %class.C, align 1 50 %0 = load i8, i8* @argc, align 1 51 tail call void @llvm.dbg.value(metadata i8 %0, i64 0, metadata !22, metadata !23), !dbg !24 52 %conv = sext i8 %0 to i32 53 tail call void @llvm.dbg.value(metadata %class.C* %c, i64 0, metadata !21, metadata !25), !dbg !24 54 %call = call i32 (%class.C*, i8, i8, i8, ...) @test_function(%class.C* %c, i8 signext 0, i8 signext %0, i8 signext 0, i32 %conv) 55 %1 = load i8, i8* @argc, align 1 56 call void @llvm.dbg.value(metadata %class.C* %c, i64 0, metadata !21, metadata !25), !dbg !24 57 %call2 = call i32 (%class.C*, i8, i8, i8, ...) @test_function(%class.C* %c, i8 signext 0, i8 signext %1, i8 signext 0, i32 %conv) 58 ret void 59 } 60 61 ; Function Attrs: nounwind readnone 62 63 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #0 64 65 attributes #0 = { nounwind readnone } 66 67 !llvm.dbg.cu = !{!4} 68 !llvm.module.flags = !{!15, !16} 69 70 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 71 !1 = !DIGlobalVariable(name: "argc", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true) 72 !2 = !DIFile(filename: "test.cpp", directory: "") 73 !3 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) 74 !4 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !5, retainedTypes: !6, globals: !14, imports: !5) 75 !5 = !{} 76 !6 = !{!7} 77 !7 = !DICompositeType(tag: DW_TAG_class_type, name: "C", file: !2, line: 2, size: 8, align: 8, elements: !8, identifier: "_ZTS1C") 78 !8 = !{!9} 79 !9 = !DISubprogram(name: "test", scope: !7, file: !2, type: !10, isLocal: false, isDefinition: false, isOptimized: false) 80 !10 = !DISubroutineType(types: !11) 81 !11 = !{!12, !13, !3, !3, !3, null} 82 !12 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 83 !13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64, align: 64, flags: DIFlagArtificial) 84 !14 = !{!0} 85 !15 = !{i32 2, !"Dwarf Version", i32 4} 86 !16 = !{i32 2, !"Debug Info Version", i32 3} 87 !17 = distinct !DISubprogram(name: "test_with_debug", linkageName: "test_with_debug", scope: !2, file: !2, line: 6, type: !18, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !4, retainedNodes: !20) 88 !18 = !DISubroutineType(types: !19) 89 !19 = !{null} 90 !20 = !{!21, !22} 91 !21 = !DILocalVariable(name: "c", scope: !17, file: !2, line: 7, type: !7) 92 !22 = !DILocalVariable(name: "lc", scope: !17, file: !2, line: 8, type: !3) 93 !23 = !DIExpression() 94 !24 = !DILocation(line: 0, scope: !17) 95 !25 = !DIExpression(DW_OP_deref) 96 97