xref: /llvm-project/llvm/test/Transforms/Reassociate/undef_intrinsics_when_deleting_instructions.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; RUN: opt < %s -passes=reassociate -S | FileCheck %s
2; RUN: opt < %s -passes=reassociate -S --try-experimental-debuginfo-iterators | FileCheck %s
3
4; Check that reassociate pass now undefs debug intrinsics that reference a value
5; that gets dropped and cannot be salvaged.
6
7; CHECK-NOT: %add = fadd fast float %a, %b
8; CHECK: #dbg_value(float poison, [[VAR_X:![0-9]+]], !DIExpression(),
9
10; CHECK-LABEL: if.then:
11; CHECK-NOT: %add1 = fadd fast float %add, %c
12; CHECK: #dbg_value(float poison, [[VAR_Y:![0-9]+]], !DIExpression(),
13; CHECK-LABEL: !0 =
14; CHECK-DAG: [[VAR_Y]] = !DILocalVariable(name: "y"
15; CHECK-DAG: [[VAR_X]] = !DILocalVariable(name: "x"
16
17define float @"?foo@@YAMMMMM@Z"(float %a, float %b, float %c, float %d) !dbg !8 {
18entry:
19  call void @llvm.dbg.value(metadata float %d, metadata !12, metadata !DIExpression()), !dbg !13
20  call void @llvm.dbg.value(metadata float %c, metadata !14, metadata !DIExpression()), !dbg !13
21  call void @llvm.dbg.value(metadata float %b, metadata !15, metadata !DIExpression()), !dbg !13
22  call void @llvm.dbg.value(metadata float %a, metadata !16, metadata !DIExpression()), !dbg !13
23  %add = fadd fast float %a, %b, !dbg !17
24  call void @llvm.dbg.value(metadata float %add, metadata !18, metadata !DIExpression()), !dbg !13
25  %cmp = fcmp fast oeq float %d, 4.000000e+00, !dbg !19
26  br i1 %cmp, label %if.then, label %return, !dbg !19
27
28if.then:                                          ; preds = %entry
29  %add1 = fadd fast float %add, %c, !dbg !20
30  call void @llvm.dbg.value(metadata float %add1, metadata !23, metadata !DIExpression()), !dbg !24
31  %sub = fsub fast float %add, 1.200000e+01, !dbg !25
32  %sub2 = fsub fast float %add1, %sub, !dbg !25
33  %mul = fmul fast float %sub2, 2.000000e+01, !dbg !25
34  %div = fdiv fast float %mul, 3.000000e+00, !dbg !25
35  br label %return, !dbg !25
36
37return:                                           ; preds = %entry, %if.then
38  %retval.0 = phi float [ %div, %if.then ], [ 0.000000e+00, %entry ], !dbg !13
39  ret float %retval.0, !dbg !26
40}
41
42declare void @llvm.dbg.value(metadata, metadata, metadata)
43
44!llvm.dbg.cu = !{!0}
45!llvm.module.flags = !{!3, !4, !5, !6}
46!llvm.ident = !{!7}
47
48!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
49!1 = !DIFile(filename: "undef_intrinsics_when_deleting_instructions.cpp", directory: "/")
50!2 = !{}
51!3 = !{i32 2, !"CodeView", i32 1}
52!4 = !{i32 2, !"Debug Info Version", i32 3}
53!5 = !{i32 1, !"wchar_size", i32 2}
54!6 = !{i32 7, !"PIC Level", i32 2}
55!7 = !{!"clang version 11.0.0"}
56!8 = distinct !DISubprogram(name: "foo", linkageName: "?foo@@YAMMMMM@Z", scope: !1, file: !1, line: 1, type: !9, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
57!9 = !DISubroutineType(types: !10)
58!10 = !{!11, !11, !11, !11, !11}
59!11 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
60!12 = !DILocalVariable(name: "d", arg: 4, scope: !8, file: !1, line: 1, type: !11)
61!13 = !DILocation(line: 0, scope: !8)
62!14 = !DILocalVariable(name: "c", arg: 3, scope: !8, file: !1, line: 1, type: !11)
63!15 = !DILocalVariable(name: "b", arg: 2, scope: !8, file: !1, line: 1, type: !11)
64!16 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 1, type: !11)
65!17 = !DILocation(line: 2, scope: !8)
66!18 = !DILocalVariable(name: "x", scope: !8, file: !1, line: 2, type: !11)
67!19 = !DILocation(line: 3, scope: !8)
68!20 = !DILocation(line: 4, scope: !21)
69!21 = distinct !DILexicalBlock(scope: !22, file: !1, line: 3)
70!22 = distinct !DILexicalBlock(scope: !8, file: !1, line: 3)
71!23 = !DILocalVariable(name: "y", scope: !21, file: !1, line: 4, type: !11)
72!24 = !DILocation(line: 0, scope: !21)
73!25 = !DILocation(line: 5, scope: !21)
74!26 = !DILocation(line: 8, scope: !8)
75