Debian Codegraph @

llvm/test/CodeGen/BPF/BTF/local-var-readonly-1.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 char *str = "abcd";
8 ; const struct {
9 ; unsigned a[4];
10 ; } val = { .a = {2, 3, 4, 5} };
11 ; foo(str);
12 ; foo(&val);
13 ; return 0;
14 ; }
15 ; Compilation flag:
16 ; clang -target bpf -O2 -g -S -emit-llvm t.c
17
18 %struct.anon = type { [4 x i32] }
19
20 @.str = private unnamed_addr constant [5 x i8] c"abcd\00", align 1
21 @__const.test.val = private unnamed_addr constant %struct.anon { [4 x i32] [i32 2, i32 3, i32 4, i32 5] }, align 4
22
23 ; Function Attrs: nounwind
24 define dso_local i32 @test() local_unnamed_addr !dbg !7 {
25 entry:
26 %val = alloca %struct.anon, align 4
27 call void @llvm.dbg.value(metadata ptr @.str, metadata !12, metadata !DIExpression()), !dbg !25
28 call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %val), !dbg !26
29 call void @llvm.dbg.declare(metadata ptr %val, metadata !16, metadata !DIExpression()), !dbg !27
30 call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 dereferenceable(16) %val, ptr nonnull align 4 dereferenceable(16) @__const.test.val, i64 16, i1 false), !dbg !27
31 tail call void @foo(ptr @.str), !dbg !28
32 call void @foo(ptr nonnull %val), !dbg !29
33 call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %val), !dbg !30
34 ret i32 0, !dbg !31
35 }
36
37 ; the initial value of "str" is stored in section .rodata.str1.1
38 ; the initial value of "val" is stored in section .rodata.cst16
39 ; CHECK-NOT: BTF_KIND_DATASEC
40
41 ; Function Attrs: argmemonly nounwind willreturn
42 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
43
44 ; Function Attrs: nounwind readnone speculatable willreturn
45 declare void @llvm.dbg.declare(metadata, metadata, metadata)
46
47 ; Function Attrs: argmemonly nounwind willreturn
48 declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)
49
50 declare !dbg !32 dso_local void @foo(ptr) local_unnamed_addr
51
52 ; Function Attrs: argmemonly nounwind willreturn
53 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
54
55 ; Function Attrs: nounwind readnone speculatable willreturn
56 declare void @llvm.dbg.value(metadata, metadata, metadata)
57
58 !llvm.dbg.cu = !{!0}
59 !llvm.module.flags = !{!3, !4, !5}
60 !llvm.ident = !{!6}
61
62 !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)
63 !1 = !DIFile(filename: "t.c", directory: "/tmp/home/yhs/tmp")
64 !2 = !{}
65 !3 = !{i32 7, !"Dwarf Version", i32 4}
66 !4 = !{i32 2, !"Debug Info Version", i32 3}
67 !5 = !{i32 1, !"wchar_size", i32 4}
68 !6 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 1e92cffe18a07c12042b57504dfa7fb709b833c8)"}
69 !7 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
70 !8 = !DISubroutineType(types: !9)
71 !9 = !{!10}
72 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
73 !11 = !{!12, !16}
74 !12 = !DILocalVariable(name: "str", scope: !7, file: !1, line: 3, type: !13)
75 !13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64)
76 !14 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !15)
77 !15 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
78 !16 = !DILocalVariable(name: "val", scope: !7, file: !1, line: 6, type: !17)
79 !17 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !18)
80 !18 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !7, file: !1, line: 4, size: 128, elements: !19)
81 !19 = !{!20}
82 !20 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !18, file: !1, line: 5, baseType: !21, size: 128)
83 !21 = !DICompositeType(tag: DW_TAG_array_type, baseType: !22, size: 128, elements: !23)
84 !22 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
85 !23 = !{!24}
86 !24 = !DISubrange(count: 4)
87 !25 = !DILocation(line: 0, scope: !7)
88 !26 = !DILocation(line: 4, column: 3, scope: !7)
89 !27 = !DILocation(line: 6, column: 5, scope: !7)
90 !28 = !DILocation(line: 7, column: 3, scope: !7)
91 !29 = !DILocation(line: 8, column: 3, scope: !7)
92 !30 = !DILocation(line: 10, column: 1, scope: !7)
93 !31 = !DILocation(line: 9, column: 3, scope: !7)
94 !32 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !33, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
95 !33 = !DISubroutineType(types: !34)
96 !34 = !{null, !35}
97 !35 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !36, size: 64)
98 !36 = !DIDerivedType(tag: DW_TAG_const_type, baseType: null)