73 lines · plain
1; RUN: opt -O2 %s | llvm-dis > %t12; RUN: llc -mattr=+alu32 -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK %s3; Source code:4; struct b { int d; int e; } c;5; int f() {6; return __builtin_preserve_field_info(c.e, 0);7; }8; Compilation flag:9; clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c10 11target triple = "bpf"12 13%struct.b = type { i32, i32 }14 15@c = common dso_local global %struct.b zeroinitializer, align 4, !dbg !016 17; Function Attrs: nounwind readnone18define dso_local i32 @f() local_unnamed_addr !dbg !15 {19entry:20 %0 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.bs(ptr elementtype(%struct.b) nonnull @c, i32 1, i32 1), !dbg !18, !llvm.preserve.access.index !621 %1 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %0, i64 0), !dbg !1922 ret i32 %1, !dbg !2023}24 25; CHECK: r0 = 426; CHECK: exit27 28; CHECK: .long 13 # BTF_KIND_STRUCT(id = 4)29 30; CHECK: .ascii ".text" # string offset=731; CHECK: .byte 98 # string offset=1332; CHECK: .ascii "0:1" # string offset=1933 34; CHECK: .long 16 # FieldReloc35; CHECK-NEXT: .long 7 # Field reloc section string offset=736; CHECK-NEXT: .long 137; CHECK-NEXT: .long .Ltmp{{[0-9]+}}38; CHECK-NEXT: .long 439; CHECK-NEXT: .long 1940; CHECK-NEXT: .long 041 42; Function Attrs: nounwind readnone43declare ptr @llvm.preserve.struct.access.index.p0.p0.bs(ptr, i32, i32)44 45; Function Attrs: nounwind readnone46declare i32 @llvm.bpf.preserve.field.info.p0(ptr, i64)47 48!llvm.dbg.cu = !{!2}49!llvm.module.flags = !{!11, !12, !13}50!llvm.ident = !{!14}51 52!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())53!1 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)54!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 10.0.0 (https://github.com/llvm/llvm-project.git d5509db439a1bb3f0822c42398c8b5921a665478)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None)55!3 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")56!4 = !{}57!5 = !{!0}58!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "b", file: !3, line: 1, size: 64, elements: !7)59!7 = !{!8, !10}60!8 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !6, file: !3, line: 1, baseType: !9, size: 32)61!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)62!10 = !DIDerivedType(tag: DW_TAG_member, name: "e", scope: !6, file: !3, line: 1, baseType: !9, size: 32, offset: 32)63!11 = !{i32 2, !"Dwarf Version", i32 4}64!12 = !{i32 2, !"Debug Info Version", i32 3}65!13 = !{i32 1, !"wchar_size", i32 4}66!14 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git d5509db439a1bb3f0822c42398c8b5921a665478)"}67!15 = distinct !DISubprogram(name: "f", scope: !3, file: !3, line: 2, type: !16, scopeLine: 2, isDefinition: true, isOptimized: true, unit: !2, retainedNodes: !4)68!16 = !DISubroutineType(types: !17)69!17 = !{!9}70!18 = !DILocation(line: 3, column: 42, scope: !15)71!19 = !DILocation(line: 3, column: 10, scope: !15)72!20 = !DILocation(line: 3, column: 3, scope: !15)73