xref: /minix3/external/bsd/llvm/dist/llvm/test/DebugInfo/X86/op_deref.ll (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc; RUN: llc -O0 -mtriple=x86_64-apple-darwin < %s -filetype=obj \
2*0a6a1f1dSLionel Sambuc; RUN:     | llvm-dwarfdump -debug-dump=info - \
3*0a6a1f1dSLionel Sambuc; RUN:     | FileCheck %s -check-prefix=CHECK -check-prefix=DWARF4
4*0a6a1f1dSLionel Sambuc; RUN: llc -O0 -mtriple=x86_64-apple-darwin < %s -filetype=obj -dwarf-version=3 \
5*0a6a1f1dSLionel Sambuc; RUN:     | llvm-dwarfdump -debug-dump=info - \
6*0a6a1f1dSLionel Sambuc; RUN:     | FileCheck %s -check-prefix=CHECK -check-prefix=DWARF3
7f4a2713aSLionel Sambuc
8f4a2713aSLionel Sambuc; FIXME: The location here needs to be fixed, but llvm-dwarfdump doesn't handle
9f4a2713aSLionel Sambuc; DW_AT_location lists yet.
10*0a6a1f1dSLionel Sambuc; DWARF4: DW_AT_location [DW_FORM_sec_offset]                      (0x00000000)
11*0a6a1f1dSLionel Sambuc
12*0a6a1f1dSLionel Sambuc; FIXME: The location here needs to be fixed, but llvm-dwarfdump doesn't handle
13*0a6a1f1dSLionel Sambuc; DW_AT_location lists yet.
14*0a6a1f1dSLionel Sambuc; DWARF3: DW_AT_location [DW_FORM_data4]                      (0x00000000)
15*0a6a1f1dSLionel Sambuc
16*0a6a1f1dSLionel Sambuc; CHECK-NOT: DW_TAG
17*0a6a1f1dSLionel Sambuc; CHECK: DW_AT_name [DW_FORM_strp]  ( .debug_str[0x00000067] = "vla")
18f4a2713aSLionel Sambuc
19f4a2713aSLionel Sambuc; Unfortunately llvm-dwarfdump can't unparse a list of DW_AT_locations
20f4a2713aSLionel Sambuc; right now, so we check the asm output:
21f4a2713aSLionel Sambuc; RUN: llc -O0 -mtriple=x86_64-apple-darwin %s -o - -filetype=asm | FileCheck %s -check-prefix=ASM-CHECK
22f4a2713aSLionel Sambuc; vla should have a register-indirect address at one point.
23f4a2713aSLionel Sambuc; ASM-CHECK: DEBUG_VALUE: vla <- RCX
24f4a2713aSLionel Sambuc; ASM-CHECK: DW_OP_breg2
25f4a2713aSLionel Sambuc
26*0a6a1f1dSLionel Sambuc; RUN: llvm-as %s -o - | llvm-dis - | FileCheck %s --check-prefix=PRETTY-PRINT
27*0a6a1f1dSLionel Sambuc; PRETTY-PRINT: [ DW_TAG_expression ] [DW_OP_deref]
28*0a6a1f1dSLionel Sambuc
29f4a2713aSLionel Sambucdefine void @testVLAwithSize(i32 %s) nounwind uwtable ssp {
30f4a2713aSLionel Sambucentry:
31f4a2713aSLionel Sambuc  %s.addr = alloca i32, align 4
32f4a2713aSLionel Sambuc  %saved_stack = alloca i8*
33f4a2713aSLionel Sambuc  %i = alloca i32, align 4
34f4a2713aSLionel Sambuc  store i32 %s, i32* %s.addr, align 4
35*0a6a1f1dSLionel Sambuc  call void @llvm.dbg.declare(metadata i32* %s.addr, metadata !10, metadata !{!"0x102"}), !dbg !11
36f4a2713aSLionel Sambuc  %0 = load i32* %s.addr, align 4, !dbg !12
37f4a2713aSLionel Sambuc  %1 = zext i32 %0 to i64, !dbg !12
38f4a2713aSLionel Sambuc  %2 = call i8* @llvm.stacksave(), !dbg !12
39f4a2713aSLionel Sambuc  store i8* %2, i8** %saved_stack, !dbg !12
40f4a2713aSLionel Sambuc  %vla = alloca i32, i64 %1, align 16, !dbg !12
41*0a6a1f1dSLionel Sambuc  call void @llvm.dbg.declare(metadata i32* %vla, metadata !14, metadata !30), !dbg !18
42*0a6a1f1dSLionel Sambuc  call void @llvm.dbg.declare(metadata i32* %i, metadata !19, metadata !{!"0x102"}), !dbg !20
43f4a2713aSLionel Sambuc  store i32 0, i32* %i, align 4, !dbg !21
44f4a2713aSLionel Sambuc  br label %for.cond, !dbg !21
45f4a2713aSLionel Sambuc
46f4a2713aSLionel Sambucfor.cond:                                         ; preds = %for.inc, %entry
47f4a2713aSLionel Sambuc  %3 = load i32* %i, align 4, !dbg !21
48f4a2713aSLionel Sambuc  %4 = load i32* %s.addr, align 4, !dbg !21
49f4a2713aSLionel Sambuc  %cmp = icmp slt i32 %3, %4, !dbg !21
50f4a2713aSLionel Sambuc  br i1 %cmp, label %for.body, label %for.end, !dbg !21
51f4a2713aSLionel Sambuc
52f4a2713aSLionel Sambucfor.body:                                         ; preds = %for.cond
53f4a2713aSLionel Sambuc  %5 = load i32* %i, align 4, !dbg !23
54f4a2713aSLionel Sambuc  %6 = load i32* %i, align 4, !dbg !23
55f4a2713aSLionel Sambuc  %mul = mul nsw i32 %5, %6, !dbg !23
56f4a2713aSLionel Sambuc  %7 = load i32* %i, align 4, !dbg !23
57f4a2713aSLionel Sambuc  %idxprom = sext i32 %7 to i64, !dbg !23
58f4a2713aSLionel Sambuc  %arrayidx = getelementptr inbounds i32* %vla, i64 %idxprom, !dbg !23
59f4a2713aSLionel Sambuc  store i32 %mul, i32* %arrayidx, align 4, !dbg !23
60f4a2713aSLionel Sambuc  br label %for.inc, !dbg !25
61f4a2713aSLionel Sambuc
62f4a2713aSLionel Sambucfor.inc:                                          ; preds = %for.body
63f4a2713aSLionel Sambuc  %8 = load i32* %i, align 4, !dbg !26
64f4a2713aSLionel Sambuc  %inc = add nsw i32 %8, 1, !dbg !26
65f4a2713aSLionel Sambuc  store i32 %inc, i32* %i, align 4, !dbg !26
66f4a2713aSLionel Sambuc  br label %for.cond, !dbg !26
67f4a2713aSLionel Sambuc
68f4a2713aSLionel Sambucfor.end:                                          ; preds = %for.cond
69f4a2713aSLionel Sambuc  %9 = load i8** %saved_stack, !dbg !27
70f4a2713aSLionel Sambuc  call void @llvm.stackrestore(i8* %9), !dbg !27
71f4a2713aSLionel Sambuc  ret void, !dbg !27
72f4a2713aSLionel Sambuc}
73f4a2713aSLionel Sambuc
74*0a6a1f1dSLionel Sambucdeclare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
75f4a2713aSLionel Sambuc
76f4a2713aSLionel Sambucdeclare i8* @llvm.stacksave() nounwind
77f4a2713aSLionel Sambuc
78f4a2713aSLionel Sambucdeclare void @llvm.stackrestore(i8*) nounwind
79f4a2713aSLionel Sambuc
80f4a2713aSLionel Sambuc!llvm.dbg.cu = !{!0}
81*0a6a1f1dSLionel Sambuc!llvm.module.flags = !{!29}
82f4a2713aSLionel Sambuc
83*0a6a1f1dSLionel Sambuc!0 = !{!"0x11\0012\00clang version 3.2 (trunk 156005) (llvm/trunk 156000)\000\00\000\00\001", !28, !1, !1, !3, !1,  !1} ; [ DW_TAG_compile_unit ]
84*0a6a1f1dSLionel Sambuc!1 = !{}
85*0a6a1f1dSLionel Sambuc!3 = !{!5}
86*0a6a1f1dSLionel Sambuc!5 = !{!"0x2e\00testVLAwithSize\00testVLAwithSize\00\001\000\001\000\006\00256\000\002", !28, !6, !7, null, void (i32)* @testVLAwithSize, null, null, !1} ; [ DW_TAG_subprogram ]
87*0a6a1f1dSLionel Sambuc!6 = !{!"0x29", !28} ; [ DW_TAG_file_type ]
88*0a6a1f1dSLionel Sambuc!7 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !8, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
89*0a6a1f1dSLionel Sambuc!8 = !{null, !9}
90*0a6a1f1dSLionel Sambuc!9 = !{!"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ]
91*0a6a1f1dSLionel Sambuc!10 = !{!"0x101\00s\0016777217\000", !5, !6, !9} ; [ DW_TAG_arg_variable ]
92*0a6a1f1dSLionel Sambuc!11 = !MDLocation(line: 1, column: 26, scope: !5)
93*0a6a1f1dSLionel Sambuc!12 = !MDLocation(line: 3, column: 13, scope: !13)
94*0a6a1f1dSLionel Sambuc!13 = !{!"0xb\002\001\000", !28, !5} ; [ DW_TAG_lexical_block ]
95*0a6a1f1dSLionel Sambuc!14 = !{!"0x100\00vla\003\008192", !13, !6, !15} ; [ DW_TAG_auto_variable ]
96*0a6a1f1dSLionel Sambuc!15 = !{!"0x1\00\000\000\0032\000\000", null, null, !9, !16, i32 0, null, null, null} ; [ DW_TAG_array_type ] [line 0, size 0, align 32, offset 0] [from int]
97*0a6a1f1dSLionel Sambuc!16 = !{!17}
98*0a6a1f1dSLionel Sambuc!17 = !{!"0x21\000\00-1"}        ; [ DW_TAG_subrange_type ]
99*0a6a1f1dSLionel Sambuc!18 = !MDLocation(line: 3, column: 7, scope: !13)
100*0a6a1f1dSLionel Sambuc!19 = !{!"0x100\00i\004\000", !13, !6, !9} ; [ DW_TAG_auto_variable ]
101*0a6a1f1dSLionel Sambuc!20 = !MDLocation(line: 4, column: 7, scope: !13)
102*0a6a1f1dSLionel Sambuc!21 = !MDLocation(line: 5, column: 8, scope: !22)
103*0a6a1f1dSLionel Sambuc!22 = !{!"0xb\005\003\001", !28, !13} ; [ DW_TAG_lexical_block ]
104*0a6a1f1dSLionel Sambuc!23 = !MDLocation(line: 6, column: 5, scope: !24)
105*0a6a1f1dSLionel Sambuc!24 = !{!"0xb\005\0027\002", !28, !22} ; [ DW_TAG_lexical_block ]
106*0a6a1f1dSLionel Sambuc!25 = !MDLocation(line: 7, column: 3, scope: !24)
107*0a6a1f1dSLionel Sambuc!26 = !MDLocation(line: 5, column: 22, scope: !22)
108*0a6a1f1dSLionel Sambuc!27 = !MDLocation(line: 8, column: 1, scope: !13)
109*0a6a1f1dSLionel Sambuc!28 = !{!"bar.c", !"/Users/echristo/tmp"}
110*0a6a1f1dSLionel Sambuc!29 = !{i32 1, !"Debug Info Version", i32 2}
111*0a6a1f1dSLionel Sambuc!30 = !{!"0x102\006"} ; [ DW_TAG_expression ] [DW_OP_deref]
112