brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.1 KiB · 7878e04 Raw
125 lines · plain
1; REQUIRES: bpf-registered-target2 3;; Verify that llvm-objdump can use .BTF.ext to show CO-RE relocation data.4 5; RUN: llc --mtriple bpfel %s --filetype=obj -o - | \6; RUN:   llvm-objdump --no-addresses --no-show-raw-insn -dr - | \7; RUN:   FileCheck %s8 9; RUN: llc --mtriple bpfeb %s --filetype=obj -o - | \10; RUN:   llvm-objdump --no-addresses --no-show-raw-insn -dr - | \11; RUN:   FileCheck %s12 13;; Input generated from the following C code:14;;15;;  #define __pai __attribute__((preserve_access_index))16;;17;;  struct bar { int a; } __pai;18;;  volatile unsigned long g;19;;  void root(void) {20;;    struct bar *bar = (void *)0;21;;    g = __builtin_preserve_field_info(bar->a, 1);22;;    g = __builtin_preserve_field_info(bar->a, 2);23;;    g = __builtin_preserve_field_info(bar->a, 3);24;;    g = __builtin_preserve_field_info(bar->a, 4);25;;    g = __builtin_preserve_field_info(bar->a, 5);26;;  }27;;28;; Using the following command:29;;30;;  clang --target=bpf -g -O2 -emit-llvm -S t.c31 32; CHECK: CO-RE <byte_sz> [[[#]]] struct bar::a33; CHECK: CO-RE <field_exists> [[[#]]] struct bar::a34; CHECK: CO-RE <signed> [[[#]]] struct bar::a35; CHECK: CO-RE <lshift_u64> [[[#]]] struct bar::a36; CHECK: CO-RE <rshift_u64> [[[#]]] struct bar::a37 38@g = dso_local global i64 0, align 8, !dbg !039@"llvm.bar:1:4$0:0" = external global i32, !llvm.preserve.access.index !7 #040@"llvm.bar:2:1$0:0" = external global i32, !llvm.preserve.access.index !7 #041@"llvm.bar:3:1$0:0" = external global i32, !llvm.preserve.access.index !7 #042@"llvm.bar:4:32$0:0" = external global i32, !llvm.preserve.access.index !7 #043@"llvm.bar:5:32$0:0" = external global i32, !llvm.preserve.access.index !7 #044 45; Function Attrs: nofree nounwind memory(readwrite, argmem: none)46define dso_local void @root() local_unnamed_addr #1 !dbg !16 {47entry:48  call void @llvm.dbg.value(metadata ptr null, metadata !20, metadata !DIExpression()), !dbg !2249  %0 = load i32, ptr @"llvm.bar:1:4$0:0", align 450  %1 = tail call i32 @llvm.bpf.passthrough.i32.i32(i32 0, i32 %0)51  %conv = zext i32 %1 to i64, !dbg !2352  store volatile i64 %conv, ptr @g, align 8, !dbg !24, !tbaa !2553  %2 = load i32, ptr @"llvm.bar:2:1$0:0", align 454  %3 = tail call i32 @llvm.bpf.passthrough.i32.i32(i32 1, i32 %2)55  %conv1 = zext i32 %3 to i64, !dbg !2956  store volatile i64 %conv1, ptr @g, align 8, !dbg !30, !tbaa !2557  %4 = load i32, ptr @"llvm.bar:3:1$0:0", align 458  %5 = tail call i32 @llvm.bpf.passthrough.i32.i32(i32 2, i32 %4)59  %conv2 = zext i32 %5 to i64, !dbg !3160  store volatile i64 %conv2, ptr @g, align 8, !dbg !32, !tbaa !2561  %6 = load i32, ptr @"llvm.bar:4:32$0:0", align 462  %7 = tail call i32 @llvm.bpf.passthrough.i32.i32(i32 3, i32 %6)63  %conv3 = zext i32 %7 to i64, !dbg !3364  store volatile i64 %conv3, ptr @g, align 8, !dbg !34, !tbaa !2565  %8 = load i32, ptr @"llvm.bar:5:32$0:0", align 466  %9 = tail call i32 @llvm.bpf.passthrough.i32.i32(i32 4, i32 %8)67  %conv4 = zext i32 %9 to i64, !dbg !3568  store volatile i64 %conv4, ptr @g, align 8, !dbg !36, !tbaa !2569  ret void, !dbg !3770}71 72; Function Attrs: nofree nosync nounwind memory(none)73declare i32 @llvm.bpf.passthrough.i32.i32(i32, i32) #274 75; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)76declare void @llvm.dbg.value(metadata, metadata, metadata) #377 78attributes #0 = { "btf_ama" }79attributes #1 = { nofree nounwind memory(readwrite, argmem: none) "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }80attributes #2 = { nofree nosync nounwind memory(none) }81attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }82 83!llvm.dbg.cu = !{!2}84!llvm.module.flags = !{!11, !12, !13, !14}85!llvm.ident = !{!15}86 87!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())88!1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 4, type: !5, isLocal: false, isDefinition: true)89!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang version 17.0.0 (/home/eddy/work/llvm-project/clang 2f8c5c0afd1d79a771dd74c8fb1e5bbae6d04eb7)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)90!3 = !DIFile(filename: "t.c", directory: "/home/eddy/work/tmp", checksumkind: CSK_MD5, checksum: "ff78616039301f51cd56ee6ea1377b86")91!4 = !{!0}92!5 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !6)93!6 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned)94!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "bar", file: !3, line: 3, size: 32, elements: !8)95!8 = !{!9}96!9 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !7, file: !3, line: 3, baseType: !10, size: 32)97!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)98!11 = !{i32 7, !"Dwarf Version", i32 5}99!12 = !{i32 2, !"Debug Info Version", i32 3}100!13 = !{i32 1, !"wchar_size", i32 4}101!14 = !{i32 7, !"frame-pointer", i32 2}102!15 = !{!"clang version 17.0.0 (/home/eddy/work/llvm-project/clang 2f8c5c0afd1d79a771dd74c8fb1e5bbae6d04eb7)"}103!16 = distinct !DISubprogram(name: "root", scope: !3, file: !3, line: 5, type: !17, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !19)104!17 = !DISubroutineType(types: !18)105!18 = !{null}106!19 = !{!20}107!20 = !DILocalVariable(name: "bar", scope: !16, file: !3, line: 6, type: !21)108!21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)109!22 = !DILocation(line: 0, scope: !16)110!23 = !DILocation(line: 7, column: 7, scope: !16)111!24 = !DILocation(line: 7, column: 5, scope: !16)112!25 = !{!26, !26, i64 0}113!26 = !{!"long", !27, i64 0}114!27 = !{!"omnipotent char", !28, i64 0}115!28 = !{!"Simple C/C++ TBAA"}116!29 = !DILocation(line: 8, column: 7, scope: !16)117!30 = !DILocation(line: 8, column: 5, scope: !16)118!31 = !DILocation(line: 9, column: 7, scope: !16)119!32 = !DILocation(line: 9, column: 5, scope: !16)120!33 = !DILocation(line: 10, column: 7, scope: !16)121!34 = !DILocation(line: 10, column: 5, scope: !16)122!35 = !DILocation(line: 11, column: 7, scope: !16)123!36 = !DILocation(line: 11, column: 5, scope: !16)124!37 = !DILocation(line: 12, column: 1, scope: !16)125