Files

251 lines
17 KiB
LLVM

; ModuleID = 'bridge_xdp.c'
source_filename = "bridge_xdp.c"
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
target triple = "bpf"
%struct.anon = type { ptr, ptr, ptr, ptr }
%struct.xdp_md = type { i32, i32, i32, i32, i32, i32 }
%struct.ethhdr = type { [6 x i8], [6 x i8], i16 }
%struct.packet_stats = type { i64, i64 }
@stats_map = dso_local global %struct.anon zeroinitializer, section ".maps", align 8, !dbg !0
@_license = dso_local global [4 x i8] c"GPL\00", section "license", align 1, !dbg !30
@llvm.compiler.used = appending global [3 x ptr] [ptr @_license, ptr @bridge_filter, ptr @stats_map], section "llvm.metadata"
; Function Attrs: nounwind
define dso_local noundef i32 @bridge_filter(ptr nocapture noundef readonly %0) #0 section "xdp" !dbg !67 {
%2 = alloca i32, align 4, !DIAssignID !129
call void @llvm.dbg.assign(metadata i1 undef, metadata !95, metadata !DIExpression(), metadata !129, metadata ptr %2, metadata !DIExpression()), !dbg !130
tail call void @llvm.dbg.value(metadata ptr %0, metadata !80, metadata !DIExpression()), !dbg !130
%3 = getelementptr inbounds %struct.xdp_md, ptr %0, i64 0, i32 1, !dbg !131
%4 = load i32, ptr %3, align 4, !dbg !131, !tbaa !132
%5 = zext i32 %4 to i64, !dbg !137
%6 = inttoptr i64 %5 to ptr, !dbg !138
tail call void @llvm.dbg.value(metadata ptr %6, metadata !81, metadata !DIExpression()), !dbg !130
%7 = load i32, ptr %0, align 4, !dbg !139, !tbaa !140
%8 = zext i32 %7 to i64, !dbg !141
%9 = inttoptr i64 %8 to ptr, !dbg !142
tail call void @llvm.dbg.value(metadata ptr %9, metadata !82, metadata !DIExpression()), !dbg !130
tail call void @llvm.dbg.value(metadata ptr %9, metadata !83, metadata !DIExpression()), !dbg !130
%10 = getelementptr inbounds %struct.ethhdr, ptr %9, i64 1, !dbg !143
%11 = icmp ugt ptr %10, %6, !dbg !145
br i1 %11, label %23, label %12, !dbg !146
12: ; preds = %1
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4, !dbg !147
store i32 0, ptr %2, align 4, !dbg !148, !tbaa !149, !DIAssignID !150
call void @llvm.dbg.assign(metadata i32 0, metadata !95, metadata !DIExpression(), metadata !150, metadata ptr %2, metadata !DIExpression()), !dbg !130
%13 = call ptr inttoptr (i64 1 to ptr)(ptr noundef nonnull @stats_map, ptr noundef nonnull %2) #4, !dbg !151
tail call void @llvm.dbg.value(metadata ptr %13, metadata !96, metadata !DIExpression()), !dbg !130
%14 = icmp eq ptr %13, null, !dbg !152
br i1 %14, label %22, label %15, !dbg !154
15: ; preds = %12
%16 = load i64, ptr %13, align 8, !dbg !155, !tbaa !157
%17 = add i64 %16, 1, !dbg !155
store i64 %17, ptr %13, align 8, !dbg !155, !tbaa !157
%18 = sub nsw i64 %5, %8, !dbg !160
%19 = getelementptr inbounds %struct.packet_stats, ptr %13, i64 0, i32 1, !dbg !161
%20 = load i64, ptr %19, align 8, !dbg !162, !tbaa !163
%21 = add i64 %18, %20, !dbg !162
store i64 %21, ptr %19, align 8, !dbg !162, !tbaa !163
br label %22, !dbg !164
22: ; preds = %15, %12
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4, !dbg !165
br label %23
23: ; preds = %1, %22
%24 = phi i32 [ 2, %22 ], [ 0, %1 ], !dbg !130
ret i32 %24, !dbg !165
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #2
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare void @llvm.dbg.value(metadata, metadata, metadata) #3
attributes #0 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }
!llvm.dbg.cu = !{!2}
!llvm.module.flags = !{!61, !62, !63, !64, !65}
!llvm.ident = !{!66}
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
!1 = distinct !DIGlobalVariable(name: "stats_map", scope: !2, file: !3, line: 12, type: !36, isLocal: false, isDefinition: true)
!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang version 18.1.8 ( 18.1.8-3.0.1.el9)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !14, globals: !20, splitDebugInlining: false, nameTableKind: None)
!3 = !DIFile(filename: "bridge_xdp.c", directory: "/root/xdp_filter")
!4 = !{!5}
!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "xdp_action", file: !6, line: 6313, baseType: !7, size: 32, elements: !8)
!6 = !DIFile(filename: "/usr/include/linux/bpf.h", directory: "")
!7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
!8 = !{!9, !10, !11, !12, !13}
!9 = !DIEnumerator(name: "XDP_ABORTED", value: 0)
!10 = !DIEnumerator(name: "XDP_DROP", value: 1)
!11 = !DIEnumerator(name: "XDP_PASS", value: 2)
!12 = !DIEnumerator(name: "XDP_TX", value: 3)
!13 = !DIEnumerator(name: "XDP_REDIRECT", value: 4)
!14 = !{!15, !16, !17}
!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
!16 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed)
!17 = !DIDerivedType(tag: DW_TAG_typedef, name: "__u16", file: !18, line: 24, baseType: !19)
!18 = !DIFile(filename: "/usr/include/asm-generic/int-ll64.h", directory: "")
!19 = !DIBasicType(name: "unsigned short", size: 16, encoding: DW_ATE_unsigned)
!20 = !{!21, !30, !0}
!21 = !DIGlobalVariableExpression(var: !22, expr: !DIExpression())
!22 = distinct !DIGlobalVariable(name: "bpf_map_lookup_elem", scope: !2, file: !23, line: 56, type: !24, isLocal: true, isDefinition: true)
!23 = !DIFile(filename: "/usr/include/bpf/bpf_helper_defs.h", directory: "")
!24 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !25)
!25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !26, size: 64)
!26 = !DISubroutineType(types: !27)
!27 = !{!15, !15, !28}
!28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !29, size: 64)
!29 = !DIDerivedType(tag: DW_TAG_const_type, baseType: null)
!30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression())
!31 = distinct !DIGlobalVariable(name: "_license", scope: !2, file: !3, line: 52, type: !32, isLocal: false, isDefinition: true)
!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 32, elements: !34)
!33 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
!34 = !{!35}
!35 = !DISubrange(count: 4)
!36 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !3, line: 7, size: 256, elements: !37)
!37 = !{!38, !44, !49, !52}
!38 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !36, file: !3, line: 8, baseType: !39, size: 64)
!39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !40, size: 64)
!40 = !DICompositeType(tag: DW_TAG_array_type, baseType: !41, size: 192, elements: !42)
!41 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!42 = !{!43}
!43 = !DISubrange(count: 6)
!44 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !36, file: !3, line: 9, baseType: !45, size: 64, offset: 64)
!45 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !46, size: 64)
!46 = !DICompositeType(tag: DW_TAG_array_type, baseType: !41, size: 32, elements: !47)
!47 = !{!48}
!48 = !DISubrange(count: 1)
!49 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !36, file: !3, line: 10, baseType: !50, size: 64, offset: 128)
!50 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !51, size: 64)
!51 = !DIDerivedType(tag: DW_TAG_typedef, name: "__u32", file: !18, line: 27, baseType: !7)
!52 = !DIDerivedType(tag: DW_TAG_member, name: "value", scope: !36, file: !3, line: 11, baseType: !53, size: 64, offset: 192)
!53 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !54, size: 64)
!54 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "packet_stats", file: !55, line: 10, size: 128, elements: !56)
!55 = !DIFile(filename: "./bridge_xdp.h", directory: "/root/xdp_filter")
!56 = !{!57, !60}
!57 = !DIDerivedType(tag: DW_TAG_member, name: "packets", scope: !54, file: !55, line: 11, baseType: !58, size: 64)
!58 = !DIDerivedType(tag: DW_TAG_typedef, name: "__u64", file: !18, line: 31, baseType: !59)
!59 = !DIBasicType(name: "unsigned long long", size: 64, encoding: DW_ATE_unsigned)
!60 = !DIDerivedType(tag: DW_TAG_member, name: "bytes", scope: !54, file: !55, line: 12, baseType: !58, size: 64, offset: 64)
!61 = !{i32 7, !"Dwarf Version", i32 4}
!62 = !{i32 2, !"Debug Info Version", i32 3}
!63 = !{i32 1, !"wchar_size", i32 4}
!64 = !{i32 7, !"frame-pointer", i32 2}
!65 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
!66 = !{!"clang version 18.1.8 ( 18.1.8-3.0.1.el9)"}
!67 = distinct !DISubprogram(name: "bridge_filter", scope: !3, file: !3, line: 15, type: !68, scopeLine: 16, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !79)
!68 = !DISubroutineType(types: !69)
!69 = !{!41, !70}
!70 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !71, size: 64)
!71 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "xdp_md", file: !6, line: 6324, size: 192, elements: !72)
!72 = !{!73, !74, !75, !76, !77, !78}
!73 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !71, file: !6, line: 6325, baseType: !51, size: 32)
!74 = !DIDerivedType(tag: DW_TAG_member, name: "data_end", scope: !71, file: !6, line: 6326, baseType: !51, size: 32, offset: 32)
!75 = !DIDerivedType(tag: DW_TAG_member, name: "data_meta", scope: !71, file: !6, line: 6327, baseType: !51, size: 32, offset: 64)
!76 = !DIDerivedType(tag: DW_TAG_member, name: "ingress_ifindex", scope: !71, file: !6, line: 6329, baseType: !51, size: 32, offset: 96)
!77 = !DIDerivedType(tag: DW_TAG_member, name: "rx_queue_index", scope: !71, file: !6, line: 6330, baseType: !51, size: 32, offset: 128)
!78 = !DIDerivedType(tag: DW_TAG_member, name: "egress_ifindex", scope: !71, file: !6, line: 6332, baseType: !51, size: 32, offset: 160)
!79 = !{!80, !81, !82, !83, !95, !96, !97}
!80 = !DILocalVariable(name: "ctx", arg: 1, scope: !67, file: !3, line: 15, type: !70)
!81 = !DILocalVariable(name: "data_end", scope: !67, file: !3, line: 17, type: !15)
!82 = !DILocalVariable(name: "data", scope: !67, file: !3, line: 18, type: !15)
!83 = !DILocalVariable(name: "eth", scope: !67, file: !3, line: 19, type: !84)
!84 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !85, size: 64)
!85 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "ethhdr", file: !86, line: 166, size: 112, elements: !87)
!86 = !DIFile(filename: "/usr/include/linux/if_ether.h", directory: "")
!87 = !{!88, !91, !92}
!88 = !DIDerivedType(tag: DW_TAG_member, name: "h_dest", scope: !85, file: !86, line: 167, baseType: !89, size: 48)
!89 = !DICompositeType(tag: DW_TAG_array_type, baseType: !90, size: 48, elements: !42)
!90 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)
!91 = !DIDerivedType(tag: DW_TAG_member, name: "h_source", scope: !85, file: !86, line: 168, baseType: !89, size: 48, offset: 48)
!92 = !DIDerivedType(tag: DW_TAG_member, name: "h_proto", scope: !85, file: !86, line: 169, baseType: !93, size: 16, offset: 96)
!93 = !DIDerivedType(tag: DW_TAG_typedef, name: "__be16", file: !94, line: 29, baseType: !17)
!94 = !DIFile(filename: "/usr/include/linux/types.h", directory: "")
!95 = !DILocalVariable(name: "key", scope: !67, file: !3, line: 26, type: !51)
!96 = !DILocalVariable(name: "stats", scope: !67, file: !3, line: 27, type: !53)
!97 = !DILocalVariable(name: "iph", scope: !98, file: !3, line: 39, type: !100)
!98 = distinct !DILexicalBlock(scope: !99, file: !3, line: 38, column: 46)
!99 = distinct !DILexicalBlock(scope: !67, file: !3, line: 38, column: 9)
!100 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !101, size: 64)
!101 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "iphdr", file: !102, line: 87, size: 160, elements: !103)
!102 = !DIFile(filename: "/usr/include/linux/ip.h", directory: "")
!103 = !{!104, !106, !107, !108, !109, !110, !111, !112, !113, !115}
!104 = !DIDerivedType(tag: DW_TAG_member, name: "ihl", scope: !101, file: !102, line: 89, baseType: !105, size: 4, flags: DIFlagBitField, extraData: i64 0)
!105 = !DIDerivedType(tag: DW_TAG_typedef, name: "__u8", file: !18, line: 21, baseType: !90)
!106 = !DIDerivedType(tag: DW_TAG_member, name: "version", scope: !101, file: !102, line: 90, baseType: !105, size: 4, offset: 4, flags: DIFlagBitField, extraData: i64 0)
!107 = !DIDerivedType(tag: DW_TAG_member, name: "tos", scope: !101, file: !102, line: 97, baseType: !105, size: 8, offset: 8)
!108 = !DIDerivedType(tag: DW_TAG_member, name: "tot_len", scope: !101, file: !102, line: 98, baseType: !93, size: 16, offset: 16)
!109 = !DIDerivedType(tag: DW_TAG_member, name: "id", scope: !101, file: !102, line: 99, baseType: !93, size: 16, offset: 32)
!110 = !DIDerivedType(tag: DW_TAG_member, name: "frag_off", scope: !101, file: !102, line: 100, baseType: !93, size: 16, offset: 48)
!111 = !DIDerivedType(tag: DW_TAG_member, name: "ttl", scope: !101, file: !102, line: 101, baseType: !105, size: 8, offset: 64)
!112 = !DIDerivedType(tag: DW_TAG_member, name: "protocol", scope: !101, file: !102, line: 102, baseType: !105, size: 8, offset: 72)
!113 = !DIDerivedType(tag: DW_TAG_member, name: "check", scope: !101, file: !102, line: 103, baseType: !114, size: 16, offset: 80)
!114 = !DIDerivedType(tag: DW_TAG_typedef, name: "__sum16", file: !94, line: 35, baseType: !17)
!115 = !DIDerivedType(tag: DW_TAG_member, scope: !101, file: !102, line: 104, baseType: !116, size: 64, offset: 96)
!116 = distinct !DICompositeType(tag: DW_TAG_union_type, scope: !101, file: !102, line: 104, size: 64, elements: !117)
!117 = !{!118, !124}
!118 = !DIDerivedType(tag: DW_TAG_member, scope: !116, file: !102, line: 104, baseType: !119, size: 64)
!119 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !116, file: !102, line: 104, size: 64, elements: !120)
!120 = !{!121, !123}
!121 = !DIDerivedType(tag: DW_TAG_member, name: "saddr", scope: !119, file: !102, line: 104, baseType: !122, size: 32)
!122 = !DIDerivedType(tag: DW_TAG_typedef, name: "__be32", file: !94, line: 31, baseType: !51)
!123 = !DIDerivedType(tag: DW_TAG_member, name: "daddr", scope: !119, file: !102, line: 104, baseType: !122, size: 32, offset: 32)
!124 = !DIDerivedType(tag: DW_TAG_member, name: "addrs", scope: !116, file: !102, line: 104, baseType: !125, size: 64)
!125 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !116, file: !102, line: 104, size: 64, elements: !126)
!126 = !{!127, !128}
!127 = !DIDerivedType(tag: DW_TAG_member, name: "saddr", scope: !125, file: !102, line: 104, baseType: !122, size: 32)
!128 = !DIDerivedType(tag: DW_TAG_member, name: "daddr", scope: !125, file: !102, line: 104, baseType: !122, size: 32, offset: 32)
!129 = distinct !DIAssignID()
!130 = !DILocation(line: 0, scope: !67)
!131 = !DILocation(line: 17, column: 41, scope: !67)
!132 = !{!133, !134, i64 4}
!133 = !{!"xdp_md", !134, i64 0, !134, i64 4, !134, i64 8, !134, i64 12, !134, i64 16, !134, i64 20}
!134 = !{!"int", !135, i64 0}
!135 = !{!"omnipotent char", !136, i64 0}
!136 = !{!"Simple C/C++ TBAA"}
!137 = !DILocation(line: 17, column: 30, scope: !67)
!138 = !DILocation(line: 17, column: 22, scope: !67)
!139 = !DILocation(line: 18, column: 37, scope: !67)
!140 = !{!133, !134, i64 0}
!141 = !DILocation(line: 18, column: 26, scope: !67)
!142 = !DILocation(line: 18, column: 18, scope: !67)
!143 = !DILocation(line: 22, column: 21, scope: !144)
!144 = distinct !DILexicalBlock(scope: !67, file: !3, line: 22, column: 9)
!145 = !DILocation(line: 22, column: 26, scope: !144)
!146 = !DILocation(line: 22, column: 9, scope: !67)
!147 = !DILocation(line: 26, column: 5, scope: !67)
!148 = !DILocation(line: 26, column: 11, scope: !67)
!149 = !{!134, !134, i64 0}
!150 = distinct !DIAssignID()
!151 = !DILocation(line: 27, column: 34, scope: !67)
!152 = !DILocation(line: 28, column: 9, scope: !153)
!153 = distinct !DILexicalBlock(scope: !67, file: !3, line: 28, column: 9)
!154 = !DILocation(line: 28, column: 9, scope: !67)
!155 = !DILocation(line: 29, column: 23, scope: !156)
!156 = distinct !DILexicalBlock(scope: !153, file: !3, line: 28, column: 16)
!157 = !{!158, !159, i64 0}
!158 = !{!"packet_stats", !159, i64 0, !159, i64 8}
!159 = !{!"long long", !135, i64 0}
!160 = !DILocation(line: 30, column: 35, scope: !156)
!161 = !DILocation(line: 30, column: 16, scope: !156)
!162 = !DILocation(line: 30, column: 22, scope: !156)
!163 = !{!158, !159, i64 8}
!164 = !DILocation(line: 31, column: 5, scope: !156)
!165 = !DILocation(line: 50, column: 1, scope: !67)