1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 ; Make sure to update the debug value after dead code elimination.
4 ; CHECK: %call = call signext i8 @b(i32 6), !dbg !39
5 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 undef, metadata !30, metadata !DIExpression()), !dbg !38
7 @e = common local_unnamed_addr global i8 0, align 1, !dbg !0
8 @c = common local_unnamed_addr global i32 0, align 4, !dbg !6
9 @d = common local_unnamed_addr global i32 0, align 4, !dbg !10
11 define signext i8 @b(i32 %f) local_unnamed_addr #0 !dbg !18 {
13 call void @llvm.dbg.value(metadata i32 %f, metadata !22, metadata !DIExpression()), !dbg !23
14 %conv = trunc i32 %f to i8, !dbg !24
15 ret i8 %conv, !dbg !25
18 define i32 @main() local_unnamed_addr #0 !dbg !26 {
20 %0 = load i8, i8* @e, align 1, !dbg !31, !tbaa !32
21 %conv = sext i8 %0 to i32, !dbg !31
22 store i32 %conv, i32* @c, align 4, !dbg !35, !tbaa !36
23 call void @llvm.dbg.value(metadata i32 -1372423381, metadata !30, metadata !DIExpression()), !dbg !38
24 %call = call signext i8 @b(i32 6), !dbg !39
25 %conv1 = sext i8 %call to i32, !dbg !39
26 call void @llvm.dbg.value(metadata i32 %conv1, metadata !30, metadata !DIExpression()), !dbg !38
27 %1 = load i32, i32* @d, align 4, !dbg !40, !tbaa !36
28 %call2 = call i32 (...) @optimize_me_not(), !dbg !41
32 declare i32 @optimize_me_not(...) local_unnamed_addr #1
33 declare void @llvm.dbg.value(metadata, metadata, metadata) #2
36 !llvm.module.flags = !{!13, !14, !15, !16}
39 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
40 !1 = distinct !DIGlobalVariable(name: "e", scope: !2, file: !3, line: 3, type: !12, isLocal: false, isDefinition: true)
41 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project b306ef12f046353ea5bda4b3b77759e57909a0db)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: GNU)
42 !3 = !DIFile(filename: "a.c", directory: "/Users/davide/llvm/build/bin")
45 !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
46 !7 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
47 !8 = !DIDerivedType(tag: DW_TAG_typedef, name: "a", file: !3, line: 1, baseType: !9)
48 !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
49 !10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())
50 !11 = distinct !DIGlobalVariable(name: "d", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
51 !12 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
52 !13 = !{i32 2, !"Dwarf Version", i32 4}
53 !14 = !{i32 2, !"Debug Info Version", i32 3}
54 !15 = !{i32 1, !"wchar_size", i32 4}
55 !16 = !{i32 7, !"PIC Level", i32 2}
56 !17 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project b306ef12f046353ea5bda4b3b77759e57909a0db)"}
57 !18 = distinct !DISubprogram(name: "b", scope: !3, file: !3, line: 4, type: !19, scopeLine: 4, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !21)
58 !19 = !DISubroutineType(types: !20)
61 !22 = !DILocalVariable(name: "f", arg: 1, scope: !18, file: !3, line: 4, type: !9)
62 !23 = !DILocation(line: 4, column: 9, scope: !18)
63 !24 = !DILocation(line: 4, column: 21, scope: !18)
64 !25 = !DILocation(line: 4, column: 14, scope: !18)
65 !26 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 5, type: !27, scopeLine: 5, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !29)
66 !27 = !DISubroutineType(types: !28)
69 !30 = !DILocalVariable(name: "l_1499", scope: !26, file: !3, line: 7, type: !8)
70 !31 = !DILocation(line: 6, column: 7, scope: !26)
71 !32 = !{!33, !33, i64 0}
72 !33 = !{!"omnipotent char", !34, i64 0}
73 !34 = !{!"Simple C/C++ TBAA"}
74 !35 = !DILocation(line: 6, column: 5, scope: !26)
75 !36 = !{!37, !37, i64 0}
76 !37 = !{!"int", !33, i64 0}
77 !38 = !DILocation(line: 7, column: 5, scope: !26)
78 !39 = !DILocation(line: 8, column: 12, scope: !26)
79 !40 = !DILocation(line: 9, column: 11, scope: !26)
80 !41 = !DILocation(line: 10, column: 3, scope: !26)
81 !42 = !DILocation(line: 11, column: 1, scope: !26)