1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -passes=instcombine -instcombine-lower-dbg-declare=0 | FileCheck %s
4 ; In this example, instcombine wants to turn "local" into an i64, since that's
5 ; how it is stored. It should keep the debug info referring to the alloca when
6 ; it does the replacement.
12 ; void escape(const ptr);
13 ; void f(struct Foo *p) {
15 ; *(__int64 *)&local = *(__int64 *)p;
19 ; ModuleID = '<stdin>'
20 source_filename = "t.c"
21 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
22 target triple = "x86_64-pc-windows-msvc19.11.25508"
24 %struct.Foo = type { i32, i32 }
26 define void @f(ptr %p) !dbg !11 {
29 ; CHECK-NEXT: [[LOCAL:%.*]] = alloca [[STRUCT_FOO:%.*]], align 4
30 ; CHECK-NEXT: #dbg_declare(ptr [[LOCAL]], [[META22:![0-9]+]], !DIExpression(), [[META23:![0-9]+]])
31 ; CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr [[P:%.*]], align 8, !dbg [[DBG24:![0-9]+]], !tbaa [[TBAA25:![0-9]+]]
32 ; CHECK-NEXT: store i64 [[TMP0]], ptr [[LOCAL]], align 4, !dbg [[DBG29:![0-9]+]], !tbaa [[TBAA25]]
33 ; CHECK-NEXT: call void @escape(ptr nonnull [[LOCAL]]), !dbg [[DBG30:![0-9]+]]
34 ; CHECK-NEXT: ret void, !dbg [[DBG31:![0-9]+]]
37 %local = alloca %struct.Foo, align 4
38 call void @llvm.dbg.declare(metadata ptr %local, metadata !22, metadata !DIExpression()), !dbg !25
39 %0 = load i64, ptr %p, align 8, !dbg !26, !tbaa !27
40 store i64 %0, ptr %local, align 4, !dbg !32, !tbaa !27
41 call void @escape(ptr %local), !dbg !34
45 declare void @llvm.dbg.declare(metadata, metadata, metadata)
47 declare void @escape(ptr)
50 !llvm.module.flags = !{!6, !7, !8, !9}
53 !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)
54 !1 = !DIFile(filename: "t.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "d7473625866433067a75fd7d03d2abf7")
57 !4 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64)
58 !5 = !DIBasicType(name: "long long int", size: 64, encoding: DW_ATE_signed)
59 !6 = !{i32 2, !"CodeView", i32 1}
60 !7 = !{i32 2, !"Debug Info Version", i32 3}
61 !8 = !{i32 1, !"wchar_size", i32 2}
62 !9 = !{i32 7, !"PIC Level", i32 2}
63 !10 = !{!"clang version 6.0.0 "}
64 !11 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 5, type: !12, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !20)
65 !12 = !DISubroutineType(types: !13)
67 !14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 64)
68 !15 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !1, line: 1, size: 64, elements: !16)
70 !17 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !15, file: !1, line: 2, baseType: !18, size: 32)
71 !18 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
72 !19 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !15, file: !1, line: 2, baseType: !18, size: 32, offset: 32)
74 !21 = !DILocalVariable(name: "p", arg: 1, scope: !11, file: !1, line: 5, type: !14)
75 !22 = !DILocalVariable(name: "local", scope: !11, file: !1, line: 6, type: !15)
76 !23 = !DILocation(line: 5, column: 20, scope: !11)
77 !24 = !DILocation(line: 6, column: 3, scope: !11)
78 !25 = !DILocation(line: 6, column: 14, scope: !11)
79 !26 = !DILocation(line: 7, column: 24, scope: !11)
80 !27 = !{!28, !28, i64 0}
81 !28 = !{!"long long", !29, i64 0}
82 !29 = !{!"omnipotent char", !30, i64 0}
83 !30 = !{!"Simple C/C++ TBAA"}
84 !31 = !DILocation(line: 7, column: 3, scope: !11)
85 !32 = !DILocation(line: 7, column: 22, scope: !11)
86 !33 = !DILocation(line: 8, column: 10, scope: !11)
87 !34 = !DILocation(line: 8, column: 3, scope: !11)
88 !35 = !DILocation(line: 9, column: 1, scope: !11)