1 ; RUN: llc < %s -march=x86-64 -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 23 %class.C = type { i8 } 24 25 @argc = global i8 0, align 1 26 27 declare i32 @test_function(%class.C*, i8 signext, i8 signext, i8 signext, ...) 28 29 ; CHECK-LABEL: test_without_debug 30 ; CHECK: movl [[A:%[a-z]+]], [[B:%[a-z]+]] 31 ; CHECK-NEXT: movl [[A]], [[C:%[a-z]+]] 32 define void @test_without_debug() { 33 entry: 34 %c = alloca %class.C, align 1 35 %0 = load i8, i8* @argc, align 1 36 %conv = sext i8 %0 to i32 37 %call = call i32 (%class.C*, i8, i8, i8, ...) @test_function(%class.C* %c, i8 signext 0, i8 signext %0, i8 signext 0, i32 %conv) 38 %1 = load i8, i8* @argc, align 1 39 %call2 = call i32 (%class.C*, i8, i8, i8, ...) @test_function(%class.C* %c, i8 signext 0, i8 signext %1, i8 signext 0, i32 %conv) 40 ret void 41 } 42 43 ; CHECK-LABEL: test_with_debug 44 ; CHECK: movl [[A]], [[B]] 45 ; CHECK-NEXT: movl [[A]], [[C]] 46 define void @test_with_debug() { 47 entry: 48 %c = alloca %class.C, align 1 49 %0 = load i8, i8* @argc, align 1 50 tail call void @llvm.dbg.value(metadata i8 %0, i64 0, metadata !19, metadata !29), !dbg !MDLocation(scope: !13) 51 %conv = sext i8 %0 to i32 52 tail call void @llvm.dbg.value(metadata %class.C* %c, i64 0, metadata !18, metadata !29), !dbg !MDLocation(scope: !13) 53 %call = call i32 (%class.C*, i8, i8, i8, ...) @test_function(%class.C* %c, i8 signext 0, i8 signext %0, i8 signext 0, i32 %conv) 54 %1 = load i8, i8* @argc, align 1 55 call void @llvm.dbg.value(metadata %class.C* %c, i64 0, metadata !18, metadata !29), !dbg !MDLocation(scope: !13) 56 %call2 = call i32 (%class.C*, i8, i8, i8, ...) @test_function(%class.C* %c, i8 signext 0, i8 signext %1, i8 signext 0, i32 %conv) 57 ret void 58 } 59 60 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) 61 62 !llvm.dbg.cu = !{!0} 63 !llvm.module.flags = !{!22, !23} 64 65 !0 = !MDCompileUnit(language: DW_LANG_C_plus_plus, file: !1, enums: !2, retainedTypes: !3, subprograms: !12, globals: !20, imports: !2) 66 !1 = !MDFile(filename: "test.cpp", directory: "") 67 !2 = !{} 68 !3 = !{!4} 69 !4 = !MDCompositeType(tag: DW_TAG_class_type, name: "C", line: 2, size: 8, align: 8, file: !1, elements: !5, identifier: "_ZTS1C") 70 !5 = !{!6} 71 !6 = !MDSubprogram(name: "test", file: !1, scope: !"_ZTS1C", type: !7) 72 !7 = !MDSubroutineType(types: !8) 73 !8 = !{!9, !10, !11, !11, !11, null} 74 !9 = !MDBasicType(encoding: DW_ATE_signed, size: 32, align: 32, name: "int") 75 !10 = !MDDerivedType(baseType: !"_ZTS1C", tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial) 76 !11 = !MDBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) 77 !12 = !{!13} 78 !13 = !MDSubprogram(name: "test_with_debug", linkageName: "test_with_debug", line: 6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 6, file: !1, scope: !14, type: !15, function: void ()* @test_with_debug, variables: !17) 79 !14 = !MDFile(filename: "test.cpp", directory: "") 80 !15 = !MDSubroutineType(types: !16) 81 !16 = !{null} 82 !17 = !{!18, !19} 83 !18 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "c", line: 7, scope: !13, file: !14, type: !"_ZTS1C") 84 !19 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "lc", line: 8, scope: !13, file: !14, type: !11) 85 !20 = !{!21} 86 !21 = !MDGlobalVariable(name: "argc", line: 1, isLocal: false, isDefinition: true, scope: null, file: !14, type: !11, variable: i8* @argc) 87 !22 = !{i32 2, !"Dwarf Version", i32 4} 88 !23 = !{i32 2, !"Debug Info Version", i32 3} 89 !25 = !MDLocation(line: 8, column: 3, scope: !13) 90 !29 = !MDExpression() 91