xref: /llvm-project/llvm/test/CodeGen/MIR/Generic/diexpression.mir (revision 9f5756abefc622de543833584e4a25ffa3e9ff02)
1# RUN: sed -e 's/STACK_EXPR//g' -e 's/BODY_EXPR//g' %s | llc -x mir -run-pass none -o - 2>&1 | FileCheck --check-prefix=EXPR-NONE %s
2# RUN: sed -e 's/STACK_EXPR/DW_OP_LLVM_arg, 0, DW_OP_dup, DW_OP_plus/g' -e 's/BODY_EXPR/DW_OP_LLVM_arg, 0, DW_OP_dup, DW_OP_plus/g' %s \
3# RUN:  | llc -x mir -run-pass none -o - 2>&1 | FileCheck --check-prefix=EXPR-SOME %s
4# RUN: sed -e 's/STACK_EXPR/DW_OP_foobar/g' -e 's/BODY_EXPR//g' %s | not llc -x mir -run-pass none -o - 2>&1 | FileCheck --check-prefix=EXPR-ERR-STACK-INVALID-OP %s
5# RUN: sed -e 's/STACK_EXPR//g' -e 's/BODY_EXPR/DW_OP_foobar/g' %s | not llc -x mir -run-pass none -o - 2>&1 | FileCheck --check-prefix=EXPR-ERR-BODY-INVALID-OP %s
6# RUN: sed -e 's/STACK_EXPR/DW_ATE_foobar/g' -e 's/BODY_EXPR//g' %s | not llc -x mir -run-pass none -o - 2>&1 | FileCheck --check-prefix=EXPR-ERR-STACK-INVALID-ATTR %s
7# RUN: sed -e 's/STACK_EXPR//g' -e 's/BODY_EXPR/DW_ATE_foobar/g' %s | not llc -x mir -run-pass none -o - 2>&1 | FileCheck --check-prefix=EXPR-ERR-BODY-INVALID-ATTR %s
8# RUN: sed -e 's/STACK_EXPR/foobar/g' -e 's/BODY_EXPR//g' %s | not llc -x mir -run-pass none -o - 2>&1 | FileCheck --check-prefix=EXPR-ERR-STACK-INVALID-INT %s
9# RUN: sed -e 's/STACK_EXPR//g' -e 's/BODY_EXPR/foobar/g' %s | not llc -x mir -run-pass none -o - 2>&1 | FileCheck --check-prefix=EXPR-ERR-BODY-INVALID-INT %s
10
11# Test that we successfully parse valid DIExpression metadata in MIR, and that
12# we reject invalid DIExpression metadata in MIR.
13
14--- |
15  define void @func() #0 !dbg !6 {
16  entry:
17    call void @llvm.dbg.value(metadata i32 0, metadata !10, metadata !DIExpression()), !dbg !12
18    ret void
19  }
20
21  declare void @llvm.dbg.value(metadata, metadata, metadata) #1
22
23  attributes #0 = { noinline nounwind optnone }
24  attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
25
26  !llvm.module.flags = !{!0, !1}
27  !llvm.ident = !{!2}
28  !llvm.dbg.cu = !{!3}
29  !llvm.debugify = !{!5, !5}
30
31  !0 = !{i32 1, !"wchar_size", i32 4}
32  !1 = !{i32 2, !"Debug Info Version", i32 3}
33  !2 = !{!"clang"}
34  !3 = distinct !DICompileUnit(language: DW_LANG_C, file: !4, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
35  !4 = !DIFile(filename: "<stdin>", directory: "/")
36  !5 = !{i32 1}
37  !6 = distinct !DISubprogram(name: "func", linkageName: "func", scope: null, file: !4, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !3, retainedNodes: !9)
38  !7 = !DISubroutineType(types: !8)
39  !8 = !{}
40  !9 = !{!10}
41  !10 = !DILocalVariable(name: "1", scope: !6, file: !4, line: 1, type: !11)
42  !11 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
43  !12 = !DILocation(line: 1, column: 1, scope: !6)
44
45...
46---
47
48# EXPR-NONE: debug-info-expression: '!DIExpression()'
49# EXPR-NONE: DBG_VALUE 0, 0, ![[#]], !DIExpression(), debug-location ![[#]]
50
51# EXPR-SOME: debug-info-expression: '!DIExpression(DW_OP_LLVM_arg, 0, DW_OP_dup, DW_OP_plus)'
52# EXPR-SOME: DBG_VALUE 0, 0, ![[#]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_dup, DW_OP_plus), debug-location ![[#]]
53
54name:            func
55stack:
56  # EXPR-ERR-STACK-INVALID-OP: <stdin>:[[#@LINE+4]]:45: invalid DWARF op 'DW_OP_foobar'
57  # EXPR-ERR-STACK-INVALID-ATTR: <stdin>:[[#@LINE+3]]:45: invalid DWARF attribute encoding 'DW_ATE_foobar'
58  # EXPR-ERR-STACK-INVALID-INT: <stdin>:[[#@LINE+2]]:45: expected unsigned integer
59  - { id: 0, size: 4, debug-info-variable: '!10', debug-info-location: '!12',
60      debug-info-expression: '!DIExpression(STACK_EXPR)' }
61body:             |
62  bb.0.entry:
63    ; EXPR-ERR-BODY-INVALID-OP: <stdin>:[[#@LINE+3]]:40: invalid DWARF op 'DW_OP_foobar'
64    ; EXPR-ERR-BODY-INVALID-ATTR: <stdin>:[[#@LINE+2]]:40: invalid DWARF attribute encoding 'DW_ATE_foobar'
65    ; EXPR-ERR-BODY-INVALID-INT: <stdin>:[[#@LINE+1]]:40: expected unsigned integer
66    DBG_VALUE 0, 0, !10, !DIExpression(BODY_EXPR), debug-location !12
67...
68