File: dbg_declare_to_value_conversions.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (55 lines) | stat: -rw-r--r-- 2,409 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
; RUN: opt < %s -passes='mem2reg' -S | FileCheck %s
; RUN: opt < %s -passes='mem2reg' -S --try-experimental-debuginfo-iterators | FileCheck %s
target datalayout = "e-p:64:64"

; An intrinsic without any expressions should always be converted.
define i64 @foo0(i64 %arg) {
  %arg.addr = alloca i64
  store i64 %arg, ptr %arg.addr
  call void @llvm.dbg.declare(metadata ptr %arg.addr, metadata !26, metadata !DIExpression()), !dbg !40
  ; CHECK-LABEL: @foo0
  ; CHECK-SAME:    (i64 [[arg:%.*]])
  ; CHECK-NEXT:    #dbg_value(i64 [[arg]], {{.*}}, !DIExpression(),
  %val = load i64, ptr %arg.addr
  ret i64 %val
}

; An intrinsic with a single deref operator should be converted preserving the deref.
define i32 @foo1(ptr %arg) {
  %arg.indirect_addr = alloca ptr
  store ptr %arg, ptr %arg.indirect_addr
  call void @llvm.dbg.declare(metadata ptr %arg.indirect_addr, metadata !25, metadata !DIExpression(DW_OP_deref)), !dbg !40
  ; CHECK-LABEL: @foo1
  ; CHECK-SAME:    (ptr [[arg:%.*]])
  ; CHECK-NEXT:    #dbg_value(ptr [[arg]], {{.*}}, !DIExpression(DW_OP_deref),
  %val = load i32, ptr %arg
  ret i32 %val
}


; An intrinsic with multiple operators should cause us to conservatively bail.
define i32 @foo2(ptr %arg) {
  %arg.indirect_addr = alloca ptr
  store ptr %arg, ptr %arg.indirect_addr
  call void @llvm.dbg.declare(metadata ptr %arg.indirect_addr, metadata !25, metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 2)), !dbg !40
  ; CHECK-LABEL: @foo2
  ; CHECK-NEXT:     #dbg_value(ptr poison, {{.*}}, !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 2),
  %val = load i32, ptr %arg
  ret i32 %val
}

declare void @llvm.dbg.declare(metadata, metadata, metadata)

!llvm.module.flags = !{!1, !2}
!llvm.dbg.cu = !{!7}

!1 = !{i32 7, !"Dwarf Version", i32 4}
!2 = !{i32 2, !"Debug Info Version", i32 3}
!3 = !DIBasicType(name: "wide type", size: 512)
!4 = !DIBasicType(name: "ptr sized type", size: 64)
!7 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !8, producer: "clang", emissionKind: FullDebug)
!8 = !DIFile(filename: "test.ll", directory: "")
!10 = distinct !DISubprogram(name: "blah", linkageName: "blah", scope: !8, file: !8, line: 7, unit: !7)
!25 = !DILocalVariable(name: "blah", arg: 1, scope: !10, file: !8, line: 7, type:!3)
!26 = !DILocalVariable(name: "ptr sized var", arg: 1, scope: !10, file: !8, line: 7, type:!4)
!40 = !DILocation(line: 7, column: 35, scope: !10)