1; RUN: opt -O2 %s | llvm-dis > %t1 2; RUN: llc -filetype=asm -o - %t1 | FileCheck %s 3; RUN: llc -mattr=+alu32 -filetype=asm -o - %t1 | FileCheck %s 4 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.c 14 15target triple = "bpf" 16 17%struct.s1 = type { i32 } 18 19; Function Attrs: nounwind readnone 20define dso_local i32 @test() local_unnamed_addr #0 !dbg !17 { 21entry: 22 call void @llvm.dbg.value(metadata ptr null, metadata !21, metadata !DIExpression()), !dbg !22 23 %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 !8 24 %1 = tail call i32 @llvm.bpf.preserve.field.info.p0.s1s(ptr %0, i64 2), !dbg !24 25 ret i32 %1, !dbg !25 26} 27 28; CHECK: .long 16 # BTF_KIND_STRUCT(id = 4) 29 30; CHECK: .ascii ".text" # string offset=10 31; CHECK: .ascii "s1" # string offset=16 32; CHECK: .byte 48 # string offset=22 33 34; CHECK: .long 16 # FieldReloc 35; CHECK-NEXT: .long 10 # Field reloc section string offset=10 36; CHECK-NEXT: .long 1 37; CHECK-NEXT: .long .Ltmp{{[0-9]+}} 38; CHECK-NEXT: .long 4 39; CHECK-NEXT: .long 22 40; CHECK-NEXT: .long 2 41 42; Function Attrs: nounwind readnone 43declare ptr @llvm.preserve.array.access.index.p0.s1s.p0.s1s(ptr, i32 immarg, i32 immarg) #1 44 45; Function Attrs: nounwind readnone 46declare i32 @llvm.bpf.preserve.field.info.p0.s1s(ptr, i64 immarg) #1 47 48; Function Attrs: nounwind readnone speculatable willreturn 49declare void @llvm.dbg.value(metadata, metadata, metadata) #2 50 51attributes #0 = { nounwind readnone "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" } 52attributes #1 = { nounwind readnone } 53attributes #2 = { nounwind readnone speculatable willreturn } 54 55!llvm.dbg.cu = !{!0} 56!llvm.module.flags = !{!13, !14, !15} 57!llvm.ident = !{!16} 58 59!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) 60!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core") 61!2 = !{!3} 62!3 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !1, line: 1, baseType: !4, size: 32, elements: !5) 63!4 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) 64!5 = !{!6} 65!6 = !DIEnumerator(name: "FIELD_EXISTENCE", value: 2, isUnsigned: true) 66!7 = !{!8} 67!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64) 68!9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s1", file: !1, line: 2, size: 32, elements: !10) 69!10 = !{!11} 70!11 = !DIDerivedType(tag: DW_TAG_member, name: "a1", scope: !9, file: !1, line: 2, baseType: !12, size: 32) 71!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 72!13 = !{i32 7, !"Dwarf Version", i32 4} 73!14 = !{i32 2, !"Debug Info Version", i32 3} 74!15 = !{i32 1, !"wchar_size", i32 4} 75!16 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 32791937d7aceb0a5e1eaabf1bb1a6dbe1639792)"} 76!17 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 3, type: !18, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !20) 77!18 = !DISubroutineType(types: !19) 78!19 = !{!12} 79!20 = !{!21} 80!21 = !DILocalVariable(name: "v", scope: !17, file: !1, line: 4, type: !8) 81!22 = !DILocation(line: 0, scope: !17) 82!23 = !DILocation(line: 5, column: 40, scope: !17) 83!24 = !DILocation(line: 5, column: 10, scope: !17) 84!25 = !DILocation(line: 5, column: 3, scope: !17) 85