81 lines · plain
1; RUN: opt -O2 %s | llvm-dis > %t12; RUN: llc -filetype=asm -o - %t1 | FileCheck %s3; RUN: llc -mattr=+alu32 -filetype=asm -o - %t1 | FileCheck %s4 5; Source:6; enum { FIELD_EXISTENCE = 2, };7; struct s1 { int a1; };8; int test() {9; struct s1 *v = 0;10; return __builtin_preserve_field_info(v[0], FIELD_EXISTENCE);11; }12; Compilation flag:13; clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c14 15target triple = "bpf"16 17%struct.s1 = type { i32 }18 19; Function Attrs: nounwind readnone20define dso_local i32 @test() local_unnamed_addr !dbg !17 {21entry:22 call void @llvm.dbg.value(metadata ptr null, metadata !21, metadata !DIExpression()), !dbg !2223 %0 = tail call ptr @llvm.preserve.array.access.index.p0.s1s.p0.s1s(ptr elementtype(%struct.s1) null, i32 0, i32 0), !dbg !23, !llvm.preserve.access.index !824 %1 = tail call i32 @llvm.bpf.preserve.field.info.p0.s1s(ptr %0, i64 2), !dbg !2425 ret i32 %1, !dbg !2526}27 28; CHECK: .long 16 # BTF_KIND_STRUCT(id = 4)29 30; CHECK: .ascii ".text" # string offset=1031; CHECK: .ascii "s1" # string offset=1632; CHECK: .byte 48 # string offset=2233 34; CHECK: .long 16 # FieldReloc35; CHECK-NEXT: .long 10 # Field reloc section string offset=1036; CHECK-NEXT: .long 137; CHECK-NEXT: .long .Ltmp{{[0-9]+}}38; CHECK-NEXT: .long 439; CHECK-NEXT: .long 2240; CHECK-NEXT: .long 241 42; Function Attrs: nounwind readnone43declare ptr @llvm.preserve.array.access.index.p0.s1s.p0.s1s(ptr, i32 immarg, i32 immarg)44 45; Function Attrs: nounwind readnone46declare i32 @llvm.bpf.preserve.field.info.p0.s1s(ptr, i64 immarg)47 48; Function Attrs: nounwind readnone speculatable willreturn49declare void @llvm.dbg.value(metadata, metadata, metadata)50 51!llvm.dbg.cu = !{!0}52!llvm.module.flags = !{!13, !14, !15}53!llvm.ident = !{!16}54 55!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 32791937d7aceb0a5e1eaabf1bb1a6dbe1639792)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !7, splitDebugInlining: false, nameTableKind: None)56!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")57!2 = !{!3}58!3 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !1, line: 1, baseType: !4, size: 32, elements: !5)59!4 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)60!5 = !{!6}61!6 = !DIEnumerator(name: "FIELD_EXISTENCE", value: 2, isUnsigned: true)62!7 = !{!8}63!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)64!9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s1", file: !1, line: 2, size: 32, elements: !10)65!10 = !{!11}66!11 = !DIDerivedType(tag: DW_TAG_member, name: "a1", scope: !9, file: !1, line: 2, baseType: !12, size: 32)67!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)68!13 = !{i32 7, !"Dwarf Version", i32 4}69!14 = !{i32 2, !"Debug Info Version", i32 3}70!15 = !{i32 1, !"wchar_size", i32 4}71!16 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 32791937d7aceb0a5e1eaabf1bb1a6dbe1639792)"}72!17 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 3, type: !18, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !20)73!18 = !DISubroutineType(types: !19)74!19 = !{!12}75!20 = !{!21}76!21 = !DILocalVariable(name: "v", scope: !17, file: !1, line: 4, type: !8)77!22 = !DILocation(line: 0, scope: !17)78!23 = !DILocation(line: 5, column: 40, scope: !17)79!24 = !DILocation(line: 5, column: 10, scope: !17)80!25 = !DILocation(line: 5, column: 3, scope: !17)81