[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / llvm / test / CodeGen / BPF / BTF / local-var-readonly-2.ll
blob798f3d615aebda58b6c2065b64403edcbd3a3efa
1 ; RUN: llc -march=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
2 ; RUN: llc -march=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
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
17 %struct.anon = type { [4 x i32], i8 }
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
21 ; Function Attrs: nounwind
22 define dso_local i32 @test() local_unnamed_addr #0 !dbg !7 {
23 entry:
24   %val = alloca %struct.anon, align 4
25   call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %val) #4, !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) #4, !dbg !25
29   call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %val) #4, !dbg !26
30   ret i32 0, !dbg !27
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
38 ; CHECK:             .ascii  ".rodata"                       # string offset=42
40 ; Function Attrs: argmemonly nounwind willreturn
41 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
43 ; Function Attrs: nounwind readnone speculatable willreturn
44 declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
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) #1
49 declare !dbg !28 dso_local void @foo(ptr) local_unnamed_addr #3
51 ; Function Attrs: argmemonly nounwind willreturn
52 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
54 attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
55 attributes #1 = { argmemonly nounwind willreturn }
56 attributes #2 = { nounwind readnone speculatable willreturn }
57 attributes #3 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
58 attributes #4 = { nounwind }
60 !llvm.dbg.cu = !{!0}
61 !llvm.module.flags = !{!3, !4, !5}
62 !llvm.ident = !{!6}
64 !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)
65 !1 = !DIFile(filename: "t.c", directory: "/tmp/home/yhs/tmp")
66 !2 = !{}
67 !3 = !{i32 7, !"Dwarf Version", i32 4}
68 !4 = !{i32 2, !"Debug Info Version", i32 3}
69 !5 = !{i32 1, !"wchar_size", i32 4}
70 !6 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 1e92cffe18a07c12042b57504dfa7fb709b833c8)"}
71 !7 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
72 !8 = !DISubroutineType(types: !9)
73 !9 = !{!10}
74 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
75 !11 = !{!12}
76 !12 = !DILocalVariable(name: "val", scope: !7, file: !1, line: 6, type: !13)
77 !13 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !14)
78 !14 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !7, file: !1, line: 3, size: 160, elements: !15)
79 !15 = !{!16, !21}
80 !16 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !14, file: !1, line: 4, baseType: !17, size: 128)
81 !17 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, size: 128, elements: !19)
82 !18 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
83 !19 = !{!20}
84 !20 = !DISubrange(count: 4)
85 !21 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !14, file: !1, line: 5, baseType: !22, size: 8, offset: 128)
86 !22 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
87 !23 = !DILocation(line: 3, column: 3, scope: !7)
88 !24 = !DILocation(line: 6, column: 5, scope: !7)
89 !25 = !DILocation(line: 7, column: 3, scope: !7)
90 !26 = !DILocation(line: 9, column: 1, scope: !7)
91 !27 = !DILocation(line: 8, column: 3, scope: !7)
92 !28 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !29, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
93 !29 = !DISubroutineType(types: !30)
94 !30 = !{null, !31}
95 !31 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !32, size: 64)
96 !32 = !DIDerivedType(tag: DW_TAG_const_type, baseType: null)