xref: /llvm-project/llvm/test/DebugInfo/X86/instcombine-instrinsics.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; RUN: opt %s -O2 -S -o - | FileCheck %s
2; RUN: opt --try-experimental-debuginfo-iterators %s -O2 -S -o - | FileCheck %s
3; Verify that we emit the same intrinsic at most once.
4; rdar://problem/13056109
5;
6; CHECK: #dbg_value(ptr %p
7; CHECK-NOT: #dbg_value(ptr %p
8; CHECK-NEXT: call i32 @foo
9; CHECK: ret
10;
11;
12; typedef struct {
13;   long i;
14; } i14;
15;
16; int foo(ptr);
17;
18;   void init() {
19;     ptr p = 0;
20;     foo(&p);
21;     p->i |= 4;
22;     foo(&p);
23;   }
24;
25; ModuleID = 'instcombine_intrinsics.c'
26target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
27target triple = "x86_64-apple-macosx10.9.0"
28
29%struct.i14 = type { i64 }
30
31; Function Attrs: nounwind ssp uwtable
32define void @init() #0 !dbg !4 {
33  %p = alloca ptr, align 8
34  call void @llvm.dbg.declare(metadata ptr %p, metadata !11, metadata !DIExpression()), !dbg !18
35  store ptr null, ptr %p, align 8, !dbg !18
36  %1 = call i32 @foo(ptr %p), !dbg !19
37  %2 = load ptr, ptr %p, align 8, !dbg !20
38  %3 = load i64, ptr %2, align 8, !dbg !20
39  %4 = or i64 %3, 4, !dbg !20
40  store i64 %4, ptr %2, align 8, !dbg !20
41  %5 = call i32 @foo(ptr %p), !dbg !21
42  ret void, !dbg !22
43}
44
45; Function Attrs: nounwind readnone
46declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
47
48declare i32 @foo(ptr)
49
50attributes #0 = { nounwind ssp uwtable }
51attributes #1 = { nounwind readnone }
52
53!llvm.dbg.cu = !{!0}
54!llvm.module.flags = !{!8, !9}
55!llvm.ident = !{!10}
56
57!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
58!1 = !DIFile(filename: "instcombine_intrinsics.c", directory: "")
59!2 = !{}
60!4 = distinct !DISubprogram(name: "init", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !0, scopeLine: 7, file: !1, scope: !5, type: !6, retainedNodes: !2)
61!5 = !DIFile(filename: "instcombine_intrinsics.c", directory: "")
62!6 = !DISubroutineType(types: !7)
63!7 = !{null}
64!8 = !{i32 2, !"Dwarf Version", i32 2}
65!9 = !{i32 1, !"Debug Info Version", i32 3}
66!10 = !{!"clang version 3.5.0 "}
67!11 = !DILocalVariable(name: "p", line: 8, scope: !4, file: !5, type: !12)
68!12 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !13)
69!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "i14", line: 3, file: !1, baseType: !14)
70!14 = !DICompositeType(tag: DW_TAG_structure_type, line: 1, size: 64, align: 64, file: !1, elements: !15)
71!15 = !{!16}
72!16 = !DIDerivedType(tag: DW_TAG_member, name: "i", line: 2, size: 64, align: 64, file: !1, scope: !14, baseType: !17)
73!17 = !DIBasicType(tag: DW_TAG_base_type, name: "long int", size: 64, align: 64, encoding: DW_ATE_signed)
74!18 = !DILocation(line: 8, scope: !4)
75!19 = !DILocation(line: 9, scope: !4)
76!20 = !DILocation(line: 10, scope: !4)
77!21 = !DILocation(line: 11, scope: !4)
78!22 = !DILocation(line: 12, scope: !4)
79