xref: /llvm-project/llvm/test/DebugInfo/X86/dbg-rust-valid-enum-as-scope.ll (revision ca715de4bcf31085ee7a35aaf60843e994801f10)
1; RUN: %llc_dwarf -filetype=obj -o - %s | llvm-dwarfdump -| FileCheck --implicit-check-not=DW_TAG --implicit-check-not=NULL %s
2; CHECK: DW_TAG_compile_unit
3; CHECK:   DW_AT_language	(DW_LANG_Rust)
4; CHECK:   DW_TAG_namespace
5; CHECK:     DW_TAG_enumeration_type
6; CHECK:     DW_AT_type (0x{{[0-9A-Fa-f]+}} "u8")
7; CHECK:     DW_AT_name	("E")
8; CHECK:       DW_TAG_enumerator
9; CHECK:       DW_TAG_enumerator
10; CHECK:       DW_TAG_subprogram
11; CHECK:         DW_AT_name	("f")
12; CHECK:         DW_TAG_formal_parameter
13; CHECK:         NULL
14; CHECK:       NULL
15; CHECK:     NULL
16; CHECK:   DW_TAG_base_type
17; CHECK:     DW_AT_name ("u8")
18; CHECK:   DW_TAG_pointer_type
19; CHECK:   NULL
20
21; This file comes from rustc output, with the input program
22;         pub enum E { A, B }
23;         impl E {
24;             pub fn f(&self) {}
25;         }
26; compiled with `rustc --crate-type=lib a.rs --emit llvm-ir -g` and
27; copying the resulting `a.ll` file to here. This was done with rustc
28; at nightly from 2021-09-28 (git 8f8092cc3), but rustc 1.57 should
29; produce similar or identical output.
30
31; ModuleID = 'a.a146b597-cgu.0'
32source_filename = "a.a146b597-cgu.0"
33target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
34target triple = "x86_64-apple-macosx10.7.0"
35
36; a::E::f
37; Function Attrs: uwtable
38define void @_ZN1a1E1f17h4fcb50ce732fb2a7E(ptr align 1 dereferenceable(1) %self) unnamed_addr #0 !dbg !13 {
39start:
40  %self.dbg.spill = alloca ptr, align 8
41  store ptr %self, ptr %self.dbg.spill, align 8
42  call void @llvm.dbg.declare(metadata ptr %self.dbg.spill, metadata !19, metadata !DIExpression()), !dbg !21
43  ret void, !dbg !22
44}
45
46; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
47declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
48
49attributes #0 = { uwtable "frame-pointer"="all" "probe-stack"="__rust_probestack" "target-cpu"="core2" }
50attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
51
52!llvm.module.flags = !{!0, !1, !2}
53!llvm.dbg.cu = !{!3}
54
55!0 = !{i32 7, !"PIC Level", i32 2}
56!1 = !{i32 2, !"Dwarf Version", i32 2}
57!2 = !{i32 2, !"Debug Info Version", i32 3}
58!3 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !4, producer: "clang LLVM (rustc version 1.57.0-nightly (8f8092cc3 2021-09-28))", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !5)
59!4 = !DIFile(filename: "a.rs/@/a.a146b597-cgu.0", directory: "/Users/augie")
60!5 = !{!6}
61!6 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E", scope: !8, file: !7, baseType: !9, size: 8, align: 8, flags: DIFlagEnumClass, elements: !10)
62!7 = !DIFile(filename: "<unknown>", directory: "")
63!8 = !DINamespace(name: "a", scope: null)
64!9 = !DIBasicType(name: "u8", size: 8, encoding: DW_ATE_unsigned)
65!10 = !{!11, !12}
66!11 = !DIEnumerator(name: "A", value: 0)
67!12 = !DIEnumerator(name: "B", value: 1)
68!13 = distinct !DISubprogram(name: "f", linkageName: "_ZN1a1E1f17h4fcb50ce732fb2a7E", scope: !6, file: !14, line: 3, type: !15, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !3, templateParams: !20, retainedNodes: !18)
69!14 = !DIFile(filename: "a.rs", directory: "/Users/augie", checksumkind: CSK_MD5, checksum: "ab4ce84c27ef6fd0be1ef78e8131faa8")
70!15 = !DISubroutineType(types: !16)
71!16 = !{null, !17}
72!17 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "&E", baseType: !6, size: 64, align: 64, dwarfAddressSpace: 0)
73!18 = !{!19}
74!19 = !DILocalVariable(name: "self", arg: 1, scope: !13, file: !14, line: 3, type: !17)
75!20 = !{}
76!21 = !DILocation(line: 3, column: 14, scope: !13)
77!22 = !DILocation(line: 3, column: 23, scope: !13)
78