Debian Codegraph @

llvm/test/CodeGen/BPF/BTF/local-var-readonly-2.ll

raw
1 ; RUN: llc -mtriple=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
2 ; RUN: llc -mtriple=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
3 ;
4 ; Source:
5 ; void foo(const ptr);
6 ; int test() {
7 ; const struct {
8 ; unsigned a[4];
9 ; char b;
10 ; } val = { .a = {2, 3, 4, 5}, .b = 4 };
11 ; foo(&val);
12 ; return 0;
13 ; }
14 ; Compilation flag:
15 ; clang -target bpf -O2 -g -S -emit-llvm t.c
16
17 %struct.anon = type { [4 x i32], i8 }
18
19 @__const.test.val = private unnamed_addr constant %struct.anon { [4 x i32] [i32 2, i32 3, i32 4, i32 5], i8 4 }, align 4
20
21 ; Function Attrs: nounwind
22 define dso_local i32 @test() local_unnamed_addr !dbg !7 {
23 entry:
24 %val = alloca %struct.anon, align 4
25 call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %val), !dbg !23
26 call void @llvm.dbg.declare(metadata ptr %val, metadata !12, metadata !DIExpression()), !dbg !24
27 call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 dereferenceable(20) %val, ptr nonnull align 4 dereferenceable(20) @__const.test.val, i64 20, i1 false), !dbg !24
28 call void @foo(ptr nonnull %val), !dbg !25
29 call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %val), !dbg !26
30 ret i32 0, !dbg !27
31 }
32
33 ; the init value of local variable "val" is stored in .rodata section
34 ; CHECK: .long 42 # BTF_KIND_DATASEC
35 ; CHECK-NEXT: .long 251658240 # 0xf000000
36 ; CHECK-NEXT: .long 0
37
38 ; CHECK: .ascii ".rodata" # string offset=42
39
40 ; Function Attrs: argmemonly nounwind willreturn
41 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
42
43 ; Function Attrs: nounwind readnone speculatable willreturn
44 declare void @llvm.dbg.declare(metadata, metadata, metadata)
45
46 ; Function Attrs: argmemonly nounwind willreturn
47 declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)
48
49 declare !dbg !28 dso_local void @foo(ptr) local_unnamed_addr
50
51 ; Function Attrs: argmemonly nounwind willreturn
52 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
53
54 !llvm.dbg.cu = !{!0}
55 !llvm.module.flags = !{!3, !4, !5}
56 !llvm.ident = !{!6}
57
58 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 1e92cffe18a07c12042b57504dfa7fb709b833c8)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
59 !1 = !DIFile(filename: "t.c", directory: "/tmp/home/yhs/tmp")
60 !2 = !{}
61 !3 = !{i32 7, !"Dwarf Version", i32 4}
62 !4 = !{i32 2, !"Debug Info Version", i32 3}
63 !5 = !{i32 1, !"wchar_size", i32 4}
64 !6 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 1e92cffe18a07c12042b57504dfa7fb709b833c8)"}
65 !7 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
66 !8 = !DISubroutineType(types: !9)
67 !9 = !{!10}
68 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
69 !11 = !{!12}
70 !12 = !DILocalVariable(name: "val", scope: !7, file: !1, line: 6, type: !13)
71 !13 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !14)
72 !14 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !7, file: !1, line: 3, size: 160, elements: !15)
73 !15 = !{!16, !21}
74 !16 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !14, file: !1, line: 4, baseType: !17, size: 128)
75 !17 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, size: 128, elements: !19)
76 !18 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
77 !19 = !{!20}
78 !20 = !DISubrange(count: 4)
79 !21 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !14, file: !1, line: 5, baseType: !22, size: 8, offset: 128)
80 !22 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
81 !23 = !DILocation(line: 3, column: 3, scope: !7)
82 !24 = !DILocation(line: 6, column: 5, scope: !7)
83 !25 = !DILocation(line: 7, column: 3, scope: !7)
84 !26 = !DILocation(line: 9, column: 1, scope: !7)
85 !27 = !DILocation(line: 8, column: 3, scope: !7)
86 !28 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !29, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
87 !29 = !DISubroutineType(types: !30)
88 !30 = !{null, !31}
89 !31 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !32, size: 64)
90 !32 = !DIDerivedType(tag: DW_TAG_const_type, baseType: null)