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