1; RUN: opt -instcombine -S %s -o - | FileCheck %s 2 3; In this example, the cast from i8* to i32* becomes trivially dead. We should 4; salvage its debug info. 5 6; C source: 7; void use_as_void(void *); 8; void f(void *p) { 9; int *q = (int *)p; 10; use_as_void(q); 11; } 12 13; ModuleID = '<stdin>' 14source_filename = "t.c" 15target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" 16target triple = "x86_64-pc-windows-msvc19.11.25508" 17 18; Function Attrs: nounwind uwtable 19define void @f(i8* %p) !dbg !11 { 20entry: 21 call void @llvm.dbg.value(metadata i8* %p, metadata !16, metadata !DIExpression()), !dbg !18 22 %0 = bitcast i8* %p to i32*, !dbg !19 23 call void @llvm.dbg.value(metadata i32* %0, metadata !17, metadata !DIExpression()), !dbg !20 24 %1 = bitcast i32* %0 to i8*, !dbg !21 25 call void @use_as_void(i8* %1), !dbg !22 26 ret void, !dbg !23 27} 28 29; CHECK-LABEL: define void @f(i8* %p) 30; CHECK: call void @llvm.dbg.value(metadata i8* %p, metadata ![[P_VAR:[0-9]+]], metadata !DIExpression()) 31; CHECK-NOT: bitcast 32; CHECK: call void @llvm.dbg.value(metadata i8* %p, metadata ![[Q_VAR:[0-9]+]], metadata !DIExpression()) 33; CHECK-NOT: bitcast 34; CHECK: ret void 35 36; CHECK: ![[P_VAR]] = !DILocalVariable(name: "p", {{.*}}) 37; CHECK: ![[Q_VAR]] = !DILocalVariable(name: "q", {{.*}}) 38 39declare void @use_as_void(i8*) 40 41declare void @llvm.dbg.value(metadata, metadata, metadata) 42 43!llvm.dbg.cu = !{!0} 44!llvm.module.flags = !{!6, !7, !8, !9} 45!llvm.ident = !{!10} 46 47!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3) 48!1 = !DIFile(filename: "t.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "56c40617ada23a8cccbd9a16bcec57af") 49!2 = !{} 50!3 = !{!4} 51!4 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64) 52!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 53!6 = !{i32 2, !"CodeView", i32 1} 54!7 = !{i32 2, !"Debug Info Version", i32 3} 55!8 = !{i32 1, !"wchar_size", i32 2} 56!9 = !{i32 7, !"PIC Level", i32 2} 57!10 = !{!"clang version 6.0.0 "} 58!11 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, type: !12, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !15) 59!12 = !DISubroutineType(types: !13) 60!13 = !{null, !14} 61!14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) 62!15 = !{!16, !17} 63!16 = !DILocalVariable(name: "p", arg: 1, scope: !11, file: !1, line: 2, type: !14) 64!17 = !DILocalVariable(name: "q", scope: !11, file: !1, line: 3, type: !4) 65!18 = !DILocation(line: 2, column: 14, scope: !11) 66!19 = !DILocation(line: 3, column: 12, scope: !11) 67!20 = !DILocation(line: 3, column: 8, scope: !11) 68!21 = !DILocation(line: 4, column: 15, scope: !11) 69!22 = !DILocation(line: 4, column: 3, scope: !11) 70!23 = !DILocation(line: 5, column: 1, scope: !11) 71