xref: /llvm-project/llvm/test/Transforms/Reassociate/reassociate_dbgvalue_discard.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=reassociate -S -o - | FileCheck %s
3
4; After reassociation m1 and m2 aren't calculated as m1=c*a and m2=c*b any longer.
5; So let's verify that the dbg.value nodes for m1 and m3 are invalidated.
6
7source_filename = "reassociate_dbgvalue_discard.c"
8target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
9target triple = "x86_64-unknown-linux-gnu"
10
11define dso_local i32 @test1(i32 %a, i32 %b, i32 %c, i32 %d) local_unnamed_addr #0 !dbg !7 {
12; CHECK-LABEL: @test1(
13; CHECK-NEXT:  entry:
14; CHECK-NEXT:      #dbg_value(i32 poison, [[META16:![0-9]+]], !DIExpression(), [[META20:![0-9]+]])
15; CHECK-NEXT:      #dbg_value(i32 poison, [[META17:![0-9]+]], !DIExpression(), [[META21:![0-9]+]])
16; CHECK-NEXT:    [[M1:%.*]] = mul i32 [[D:%.*]], [[C:%.*]], !dbg [[DBG22:![0-9]+]]
17; CHECK-NEXT:    [[M3:%.*]] = mul i32 [[M1]], [[A:%.*]], !dbg [[DBG23:![0-9]+]]
18; CHECK-NEXT:      #dbg_value(i32 [[M3]], [[META18:![0-9]+]], !DIExpression(), [[META24:![0-9]+]])
19; CHECK-NEXT:    [[M2:%.*]] = mul i32 [[D]], [[C]], !dbg [[DBG25:![0-9]+]]
20; CHECK-NEXT:    [[M4:%.*]] = mul i32 [[M2]], [[B:%.*]], !dbg [[DBG26:![0-9]+]]
21; CHECK-NEXT:      #dbg_value(i32 [[M4]], [[META19:![0-9]+]], !DIExpression(), [[META27:![0-9]+]])
22; CHECK-NEXT:    [[RES:%.*]] = xor i32 [[M3]], [[M4]]
23; CHECK-NEXT:    ret i32 [[RES]], !dbg [[DBG28:![0-9]+]]
24;
25entry:
26  %m1 = mul i32 %c, %a, !dbg !24
27  call void @llvm.dbg.value(metadata i32 %m1, metadata !16, metadata !DIExpression()), !dbg !25
28  %m2 = mul i32 %c, %b, !dbg !26
29  call void @llvm.dbg.value(metadata i32 %m2, metadata !17, metadata !DIExpression()), !dbg !27
30  %m3 = mul i32 %m1, %d, !dbg !28
31  call void @llvm.dbg.value(metadata i32 %m3, metadata !18, metadata !DIExpression()), !dbg !29
32  %m4 = mul i32 %m2, %d, !dbg !30
33  call void @llvm.dbg.value(metadata i32 %m4, metadata !19, metadata !DIExpression()), !dbg !31
34  %res = xor i32 %m3, %m4
35  ret i32 %res, !dbg !32
36}
37
38declare void @llvm.dbg.value(metadata, metadata, metadata) #1
39
40attributes #0 = { nounwind readnone uwtable }
41attributes #1 = { nounwind readnone speculatable }
42
43!llvm.dbg.cu = !{!0}
44!llvm.module.flags = !{!3, !4, !5}
45!llvm.ident = !{!6}
46
47!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 7.0.0 (trunk 330596) (llvm/trunk 330594)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
48!1 = !DIFile(filename: "reassociate_dbgvalue_discard.c", directory: "")
49!2 = !{}
50!3 = !{i32 2, !"Dwarf Version", i32 4}
51!4 = !{i32 2, !"Debug Info Version", i32 3}
52!5 = !{i32 1, !"wchar_size", i32 4}
53!6 = !{!"clang version 7.0.0 (trunk 330596) (llvm/trunk 330594)"}
54!7 = distinct !DISubprogram(name: "test1", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !11)
55!8 = !DISubroutineType(types: !9)
56!9 = !{!10, !10, !10, !10, !10}
57!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
58!11 = !{!12, !13, !14, !15, !16, !17, !18, !19}
59!12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 3, type: !10)
60!13 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 3, type: !10)
61!14 = !DILocalVariable(name: "c", arg: 3, scope: !7, file: !1, line: 3, type: !10)
62!15 = !DILocalVariable(name: "d", arg: 4, scope: !7, file: !1, line: 3, type: !10)
63!16 = !DILocalVariable(name: "t1", scope: !7, file: !1, line: 4, type: !10)
64!17 = !DILocalVariable(name: "t2", scope: !7, file: !1, line: 5, type: !10)
65!18 = !DILocalVariable(name: "t3", scope: !7, file: !1, line: 6, type: !10)
66!19 = !DILocalVariable(name: "t4", scope: !7, file: !1, line: 7, type: !10)
67!20 = !DILocation(line: 3, column: 15, scope: !7)
68!21 = !DILocation(line: 3, column: 22, scope: !7)
69!22 = !DILocation(line: 3, column: 29, scope: !7)
70!23 = !DILocation(line: 3, column: 36, scope: !7)
71!24 = !DILocation(line: 4, column: 14, scope: !7)
72!25 = !DILocation(line: 4, column: 7, scope: !7)
73!26 = !DILocation(line: 5, column: 14, scope: !7)
74!27 = !DILocation(line: 5, column: 7, scope: !7)
75!28 = !DILocation(line: 6, column: 15, scope: !7)
76!29 = !DILocation(line: 6, column: 7, scope: !7)
77!30 = !DILocation(line: 7, column: 15, scope: !7)
78!31 = !DILocation(line: 7, column: 7, scope: !7)
79!32 = !DILocation(line: 8, column: 3, scope: !7)
80