1 ; RUN: opt < %s -passes='mem2reg' -S | FileCheck %s
2 ; RUN: opt < %s -passes='mem2reg' -S --try-experimental-debuginfo-iterators | FileCheck %s
3 target datalayout = "e-p:64:64"
5 ; An intrinsic without any expressions should always be converted.
6 define i64 @foo0(i64 %arg) {
8 store i64 %arg, ptr %arg.addr
9 call void @llvm.dbg.declare(metadata ptr %arg.addr, metadata !26, metadata !DIExpression()), !dbg !40
11 ; CHECK-SAME: (i64 [[arg:%.*]])
12 ; CHECK-NEXT: #dbg_value(i64 [[arg]], {{.*}}, !DIExpression(),
13 %val = load i64, ptr %arg.addr
17 ; An intrinsic with a single deref operator should be converted preserving the deref.
18 define i32 @foo1(ptr %arg) {
19 %arg.indirect_addr = alloca ptr
20 store ptr %arg, ptr %arg.indirect_addr
21 call void @llvm.dbg.declare(metadata ptr %arg.indirect_addr, metadata !25, metadata !DIExpression(DW_OP_deref)), !dbg !40
23 ; CHECK-SAME: (ptr [[arg:%.*]])
24 ; CHECK-NEXT: #dbg_value(ptr [[arg]], {{.*}}, !DIExpression(DW_OP_deref),
25 %val = load i32, ptr %arg
30 ; An intrinsic with multiple operators should cause us to conservatively bail.
31 define i32 @foo2(ptr %arg) {
32 %arg.indirect_addr = alloca ptr
33 store ptr %arg, ptr %arg.indirect_addr
34 call void @llvm.dbg.declare(metadata ptr %arg.indirect_addr, metadata !25, metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 2)), !dbg !40
36 ; CHECK-NEXT: #dbg_value(ptr poison, {{.*}}, !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 2),
37 %val = load i32, ptr %arg
41 declare void @llvm.dbg.declare(metadata, metadata, metadata)
43 !llvm.module.flags = !{!1, !2}
46 !1 = !{i32 7, !"Dwarf Version", i32 4}
47 !2 = !{i32 2, !"Debug Info Version", i32 3}
48 !3 = !DIBasicType(name: "wide type", size: 512)
49 !4 = !DIBasicType(name: "ptr sized type", size: 64)
50 !7 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !8, producer: "clang", emissionKind: FullDebug)
51 !8 = !DIFile(filename: "test.ll", directory: "")
52 !10 = distinct !DISubprogram(name: "blah", linkageName: "blah", scope: !8, file: !8, line: 7, unit: !7)
53 !25 = !DILocalVariable(name: "blah", arg: 1, scope: !10, file: !8, line: 7, type:!3)
54 !26 = !DILocalVariable(name: "ptr sized var", arg: 1, scope: !10, file: !8, line: 7, type:!4)
55 !40 = !DILocation(line: 7, column: 35, scope: !10)