From 6cc2798491d12c8fc1876163838b3fb0ee457f45 Mon Sep 17 00:00:00 2001 From: Alastair Robertson Date: Fri, 12 Jul 2024 04:37:15 -0700 Subject: [PATCH] Codegen Tests: Remove unnecessary uses of count() function Simplify the test cases such that each is only testing the minimal functionality that it needs to. Minimises noise from changing expected results in unrelated patches. --- tests/codegen/argN_rawtracepoint.cpp | 3 +- tests/codegen/args_multiple_tracepoints.cpp | 2 +- ...rgs_multiple_tracepoints_category_wild.cpp | 2 +- .../args_multiple_tracepoints_wild.cpp | 2 +- tests/codegen/call_ntop_key.cpp | 2 +- tests/codegen/call_usym_key.cpp | 2 +- tests/codegen/iter_dereference.cpp | 2 +- tests/codegen/kfunc_dereference.cpp | 3 +- tests/codegen/kretfunc_dereference.cpp | 3 +- tests/codegen/literal_strncmp.cpp | 2 +- tests/codegen/llvm/argN_rawtracepoint.ll | 82 +++---- .../codegen/llvm/args_multiple_tracepoints.ll | 126 ++++------- ...args_multiple_tracepoints_category_wild.ll | 170 +++++---------- .../llvm/args_multiple_tracepoints_wild.ll | 126 ++++------- tests/codegen/llvm/call_ntop_key.ll | 76 +++---- tests/codegen/llvm/call_usym_key.ll | 76 +++---- tests/codegen/llvm/iter_dereference.ll | 82 +++---- tests/codegen/llvm/kfunc_dereference.ll | 82 +++---- tests/codegen/llvm/kretfunc_dereference.ll | 82 +++---- tests/codegen/llvm/literal_strncmp.ll | 175 ++++++--------- tests/codegen/llvm/string_equal_comparison.ll | 205 ++++++++---------- .../llvm/string_not_equal_comparison.ll | 205 ++++++++---------- tests/codegen/string_equal_comparison.cpp | 2 +- tests/codegen/string_not_equal_comparison.cpp | 2 +- 24 files changed, 555 insertions(+), 959 deletions(-) diff --git a/tests/codegen/argN_rawtracepoint.cpp b/tests/codegen/argN_rawtracepoint.cpp index bb9549dcb..2d0faa9cf 100644 --- a/tests/codegen/argN_rawtracepoint.cpp +++ b/tests/codegen/argN_rawtracepoint.cpp @@ -6,8 +6,7 @@ namespace codegen { TEST(codegen, argN_rawtracepoint) { - test("rawtracepoint:sched_switch { " - "@[arg0] = count(); }", + test("rawtracepoint:sched_switch { @[arg0] = 1; }", NAME); } diff --git a/tests/codegen/args_multiple_tracepoints.cpp b/tests/codegen/args_multiple_tracepoints.cpp index 7fc286611..259bd6d6f 100644 --- a/tests/codegen/args_multiple_tracepoints.cpp +++ b/tests/codegen/args_multiple_tracepoints.cpp @@ -11,7 +11,7 @@ namespace codegen { TEST(codegen, args_multiple_tracepoints) { test("tracepoint:sched:sched_one,tracepoint:sched:sched_two { " - "@[args.common_field] = count(); }", + "@[args.common_field] = 1; }", NAME); } diff --git a/tests/codegen/args_multiple_tracepoints_category_wild.cpp b/tests/codegen/args_multiple_tracepoints_category_wild.cpp index d1a4eaf58..eb0a19765 100644 --- a/tests/codegen/args_multiple_tracepoints_category_wild.cpp +++ b/tests/codegen/args_multiple_tracepoints_category_wild.cpp @@ -10,7 +10,7 @@ namespace codegen { TEST(codegen, args_multiple_tracepoints_category_wild) { - test("tracepoint:sched*:sched_* { @[args.common_field] = count(); }", NAME); + test("tracepoint:sched*:sched_* { @[args.common_field] = 1; }", NAME); } } // namespace codegen diff --git a/tests/codegen/args_multiple_tracepoints_wild.cpp b/tests/codegen/args_multiple_tracepoints_wild.cpp index 2e1ddd51c..14acbc183 100644 --- a/tests/codegen/args_multiple_tracepoints_wild.cpp +++ b/tests/codegen/args_multiple_tracepoints_wild.cpp @@ -10,7 +10,7 @@ namespace codegen { TEST(codegen, args_multiple_tracepoints_wild) { - test("tracepoint:sched:sched_* { @[args.common_field] = count(); }", NAME); + test("tracepoint:sched:sched_* { @[args.common_field] = 1; }", NAME); } } // namespace codegen diff --git a/tests/codegen/call_ntop_key.cpp b/tests/codegen/call_ntop_key.cpp index 6a653f4c9..f9aa3532d 100644 --- a/tests/codegen/call_ntop_key.cpp +++ b/tests/codegen/call_ntop_key.cpp @@ -6,7 +6,7 @@ namespace codegen { TEST(codegen, call_ntop_key) { - test("kprobe:f { @x[ntop(2, 0xFFFFFFFF)] = count()}", + test("kprobe:f { @x[ntop(2, 0xFFFFFFFF)] = 1; }", NAME); } diff --git a/tests/codegen/call_usym_key.cpp b/tests/codegen/call_usym_key.cpp index f39eec4cb..90f99de8f 100644 --- a/tests/codegen/call_usym_key.cpp +++ b/tests/codegen/call_usym_key.cpp @@ -6,7 +6,7 @@ namespace codegen { TEST(codegen, call_usym_key) { - test("kprobe:f { @x[usym(0)] = count() }", + test("kprobe:f { @x[usym(0)] = 1; }", NAME); } diff --git a/tests/codegen/iter_dereference.cpp b/tests/codegen/iter_dereference.cpp index 53ccd0388..19af9bca5 100644 --- a/tests/codegen/iter_dereference.cpp +++ b/tests/codegen/iter_dereference.cpp @@ -6,7 +6,7 @@ namespace codegen { TEST(codegen, iter_dereference) { - test("iter:task_file { @[ctx->meta->session_id] = count()}", NAME); + test("iter:task_file { @[ctx->meta->session_id] = 1; }", NAME); } } // namespace codegen diff --git a/tests/codegen/kfunc_dereference.cpp b/tests/codegen/kfunc_dereference.cpp index c59dd3179..f6eaf958a 100644 --- a/tests/codegen/kfunc_dereference.cpp +++ b/tests/codegen/kfunc_dereference.cpp @@ -6,8 +6,7 @@ namespace codegen { TEST(codegen, kfunc_dereference) { - test("kfunc:tcp_sendmsg { @[args->sk->__sk_common.skc_daddr] = count(); }", - NAME); + test("kfunc:tcp_sendmsg { @[args->sk->__sk_common.skc_daddr] = 1; }", NAME); } } // namespace codegen diff --git a/tests/codegen/kretfunc_dereference.cpp b/tests/codegen/kretfunc_dereference.cpp index cc8627f80..57081576f 100644 --- a/tests/codegen/kretfunc_dereference.cpp +++ b/tests/codegen/kretfunc_dereference.cpp @@ -6,8 +6,7 @@ namespace codegen { TEST(codegen, kretfunc_dereference) { - test("kretfunc:sk_alloc { @[retval->__sk_common.skc_daddr] = count(); }", - NAME); + test("kretfunc:sk_alloc { @[retval->__sk_common.skc_daddr] = 1; }", NAME); } } // namespace codegen diff --git a/tests/codegen/literal_strncmp.cpp b/tests/codegen/literal_strncmp.cpp index d2625b259..9de283206 100644 --- a/tests/codegen/literal_strncmp.cpp +++ b/tests/codegen/literal_strncmp.cpp @@ -6,7 +6,7 @@ namespace codegen { TEST(codegen, literal_strncmp) { - test("kretprobe:vfs_read /strncmp(comm, \"sshd\", 2)/ { @[comm] = count(); }", + test("kprobe:f { @[strncmp(comm, \"sshd\", 2)] = 1; }", NAME); } diff --git a/tests/codegen/llvm/argN_rawtracepoint.ll b/tests/codegen/llvm/argN_rawtracepoint.ll index 1daed749d..d4b2470ee 100644 --- a/tests/codegen/llvm/argN_rawtracepoint.ll +++ b/tests/codegen/llvm/argN_rawtracepoint.ll @@ -15,10 +15,9 @@ target triple = "bpf-pc-linux" ; Function Attrs: nounwind declare i64 @llvm.bpf.pseudo(i64 %0, i64 %1) #0 -define i64 @rawtracepoint_sched_switch_1(i8* %0) section "s_rawtracepoint_sched_switch_1" !dbg !55 { +define i64 @rawtracepoint_sched_switch_1(i8* %0) section "s_rawtracepoint_sched_switch_1" !dbg !51 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 + %"@_val" = alloca i64, align 8 %"@_key" = alloca i64, align 8 %1 = bitcast i8* %0 to i64* %2 = getelementptr i64, i64* %1, i64 0 @@ -26,33 +25,14 @@ entry: %3 = bitcast i64* %"@_key" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %3) store i64 %arg0, i64* %"@_key", align 8 - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, i64*)*)(%"struct map_t"* @AT_, i64* %"@_key") - %4 = bitcast i64* %lookup_elem_val to i8* + %4 = bitcast i64* %"@_val" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %4) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - -lookup_success: ; preds = %entry - %cast = bitcast i8* %lookup_elem to i64* - %5 = load i64, i64* %cast, align 8 - %6 = add i64 %5, 1 - store i64 %6, i64* %cast, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %entry - %7 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %7) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %initial_value, i64 1) - %8 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %8) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %9 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %9) - %10 = bitcast i64* %"@_key" to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %10) + store i64 1, i64* %"@_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %"@_val", i64 0) + %5 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %5) + %6 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %6) ret i64 0 } @@ -65,8 +45,8 @@ declare void @llvm.lifetime.end.p0i8(i64 immarg %0, i8* nocapture %1) #1 attributes #0 = { nounwind } attributes #1 = { argmemonly nofree nosync nounwind willreturn } -!llvm.dbg.cu = !{!51} -!llvm.module.flags = !{!54} +!llvm.dbg.cu = !{!47} +!llvm.module.flags = !{!50} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "AT_", linkageName: "global", scope: !2, file: !2, type: !3, isLocal: false, isDefinition: true) @@ -75,10 +55,10 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !4 = !{!5, !11, !16, !19} !5 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !6, size: 64) !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 160, elements: !9) +!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !9) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !9 = !{!10} -!10 = !DISubrange(count: 5, lowerBound: 0) +!10 = !DISubrange(count: 1, lowerBound: 0) !11 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !12, size: 64, offset: 64) !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) !13 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 131072, elements: !14) @@ -105,28 +85,24 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) !35 = distinct !DIGlobalVariable(name: "event_loss_counter", linkageName: "global", scope: !2, file: !2, type: !36, isLocal: false, isDefinition: true) !36 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !37) -!37 = !{!38, !43, !48, !19} +!37 = !{!38, !43, !44, !19} !38 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !39, size: 64) !39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !40, size: 64) !40 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 64, elements: !41) !41 = !{!42} !42 = !DISubrange(count: 2, lowerBound: 0) -!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !44, size: 64, offset: 64) -!44 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !45, size: 64) -!45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !46) -!46 = !{!47} -!47 = !DISubrange(count: 1, lowerBound: 0) -!48 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !49, size: 64, offset: 128) -!49 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !50, size: 64) -!50 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) -!51 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !52, globals: !53) -!52 = !{} -!53 = !{!0, !20, !34} -!54 = !{i32 2, !"Debug Info Version", i32 3} -!55 = distinct !DISubprogram(name: "rawtracepoint_sched_switch_1", linkageName: "rawtracepoint_sched_switch_1", scope: !2, file: !2, type: !56, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !51, retainedNodes: !60) -!56 = !DISubroutineType(types: !57) -!57 = !{!18, !58} -!58 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !59, size: 64) -!59 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) -!60 = !{!61} -!61 = !DILocalVariable(name: "ctx", arg: 1, scope: !55, file: !2, type: !58) +!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !6, size: 64, offset: 64) +!44 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !45, size: 64, offset: 128) +!45 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !46, size: 64) +!46 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) +!47 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !48, globals: !49) +!48 = !{} +!49 = !{!0, !20, !34} +!50 = !{i32 2, !"Debug Info Version", i32 3} +!51 = distinct !DISubprogram(name: "rawtracepoint_sched_switch_1", linkageName: "rawtracepoint_sched_switch_1", scope: !2, file: !2, type: !52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !56) +!52 = !DISubroutineType(types: !53) +!53 = !{!18, !54} +!54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !55, size: 64) +!55 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) +!56 = !{!57} +!57 = !DILocalVariable(name: "ctx", arg: 1, scope: !51, file: !2, type: !54) diff --git a/tests/codegen/llvm/args_multiple_tracepoints.ll b/tests/codegen/llvm/args_multiple_tracepoints.ll index 7506f642d..8f1d5c0da 100644 --- a/tests/codegen/llvm/args_multiple_tracepoints.ll +++ b/tests/codegen/llvm/args_multiple_tracepoints.ll @@ -15,10 +15,9 @@ target triple = "bpf-pc-linux" ; Function Attrs: nounwind declare i64 @llvm.bpf.pseudo(i64 %0, i64 %1) #0 -define i64 @tracepoint_sched_sched_one_1(i8* %0) section "s_tracepoint_sched_sched_one_1" !dbg !55 { +define i64 @tracepoint_sched_sched_one_1(i8* %0) section "s_tracepoint_sched_sched_one_1" !dbg !51 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 + %"@_val" = alloca i64, align 8 %"@_key" = alloca i64, align 8 %1 = ptrtoint i8* %0 to i64 %2 = add i64 %1, 8 @@ -27,33 +26,14 @@ entry: %5 = bitcast i64* %"@_key" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %5) store i64 %4, i64* %"@_key", align 8 - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, i64*)*)(%"struct map_t"* @AT_, i64* %"@_key") - %6 = bitcast i64* %lookup_elem_val to i8* + %6 = bitcast i64* %"@_val" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %6) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - -lookup_success: ; preds = %entry - %cast = bitcast i8* %lookup_elem to i64* - %7 = load i64, i64* %cast, align 8 - %8 = add i64 %7, 1 - store i64 %8, i64* %cast, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %entry - %9 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %9) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %initial_value, i64 1) - %10 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %10) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %11 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %11) - %12 = bitcast i64* %"@_key" to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %12) + store i64 1, i64* %"@_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %"@_val", i64 0) + %7 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %7) + %8 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %8) ret i64 1 } @@ -63,10 +43,9 @@ declare void @llvm.lifetime.start.p0i8(i64 immarg %0, i8* nocapture %1) #1 ; Function Attrs: argmemonly nofree nosync nounwind willreturn declare void @llvm.lifetime.end.p0i8(i64 immarg %0, i8* nocapture %1) #1 -define i64 @tracepoint_sched_sched_two_2(i8* %0) section "s_tracepoint_sched_sched_two_2" !dbg !62 { +define i64 @tracepoint_sched_sched_two_2(i8* %0) section "s_tracepoint_sched_sched_two_2" !dbg !58 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 + %"@_val" = alloca i64, align 8 %"@_key" = alloca i64, align 8 %1 = ptrtoint i8* %0 to i64 %2 = add i64 %1, 16 @@ -75,41 +54,22 @@ entry: %5 = bitcast i64* %"@_key" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %5) store i64 %4, i64* %"@_key", align 8 - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, i64*)*)(%"struct map_t"* @AT_, i64* %"@_key") - %6 = bitcast i64* %lookup_elem_val to i8* + %6 = bitcast i64* %"@_val" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %6) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - -lookup_success: ; preds = %entry - %cast = bitcast i8* %lookup_elem to i64* - %7 = load i64, i64* %cast, align 8 - %8 = add i64 %7, 1 - store i64 %8, i64* %cast, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %entry - %9 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %9) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %initial_value, i64 1) - %10 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %10) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %11 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %11) - %12 = bitcast i64* %"@_key" to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %12) + store i64 1, i64* %"@_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %"@_val", i64 0) + %7 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %7) + %8 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %8) ret i64 1 } attributes #0 = { nounwind } attributes #1 = { argmemonly nofree nosync nounwind willreturn } -!llvm.dbg.cu = !{!51} -!llvm.module.flags = !{!54} +!llvm.dbg.cu = !{!47} +!llvm.module.flags = !{!50} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "AT_", linkageName: "global", scope: !2, file: !2, type: !3, isLocal: false, isDefinition: true) @@ -118,10 +78,10 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !4 = !{!5, !11, !16, !19} !5 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !6, size: 64) !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 160, elements: !9) +!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !9) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !9 = !{!10} -!10 = !DISubrange(count: 5, lowerBound: 0) +!10 = !DISubrange(count: 1, lowerBound: 0) !11 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !12, size: 64, offset: 64) !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) !13 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 131072, elements: !14) @@ -148,31 +108,27 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) !35 = distinct !DIGlobalVariable(name: "event_loss_counter", linkageName: "global", scope: !2, file: !2, type: !36, isLocal: false, isDefinition: true) !36 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !37) -!37 = !{!38, !43, !48, !19} +!37 = !{!38, !43, !44, !19} !38 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !39, size: 64) !39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !40, size: 64) !40 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 64, elements: !41) !41 = !{!42} !42 = !DISubrange(count: 2, lowerBound: 0) -!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !44, size: 64, offset: 64) -!44 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !45, size: 64) -!45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !46) -!46 = !{!47} -!47 = !DISubrange(count: 1, lowerBound: 0) -!48 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !49, size: 64, offset: 128) -!49 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !50, size: 64) -!50 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) -!51 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !52, globals: !53) -!52 = !{} -!53 = !{!0, !20, !34} -!54 = !{i32 2, !"Debug Info Version", i32 3} -!55 = distinct !DISubprogram(name: "tracepoint_sched_sched_one_1", linkageName: "tracepoint_sched_sched_one_1", scope: !2, file: !2, type: !56, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !51, retainedNodes: !60) -!56 = !DISubroutineType(types: !57) -!57 = !{!18, !58} -!58 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !59, size: 64) -!59 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) -!60 = !{!61} -!61 = !DILocalVariable(name: "ctx", arg: 1, scope: !55, file: !2, type: !58) -!62 = distinct !DISubprogram(name: "tracepoint_sched_sched_two_2", linkageName: "tracepoint_sched_sched_two_2", scope: !2, file: !2, type: !56, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !51, retainedNodes: !63) -!63 = !{!64} -!64 = !DILocalVariable(name: "ctx", arg: 1, scope: !62, file: !2, type: !58) +!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !6, size: 64, offset: 64) +!44 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !45, size: 64, offset: 128) +!45 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !46, size: 64) +!46 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) +!47 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !48, globals: !49) +!48 = !{} +!49 = !{!0, !20, !34} +!50 = !{i32 2, !"Debug Info Version", i32 3} +!51 = distinct !DISubprogram(name: "tracepoint_sched_sched_one_1", linkageName: "tracepoint_sched_sched_one_1", scope: !2, file: !2, type: !52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !56) +!52 = !DISubroutineType(types: !53) +!53 = !{!18, !54} +!54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !55, size: 64) +!55 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) +!56 = !{!57} +!57 = !DILocalVariable(name: "ctx", arg: 1, scope: !51, file: !2, type: !54) +!58 = distinct !DISubprogram(name: "tracepoint_sched_sched_two_2", linkageName: "tracepoint_sched_sched_two_2", scope: !2, file: !2, type: !52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !59) +!59 = !{!60} +!60 = !DILocalVariable(name: "ctx", arg: 1, scope: !58, file: !2, type: !54) diff --git a/tests/codegen/llvm/args_multiple_tracepoints_category_wild.ll b/tests/codegen/llvm/args_multiple_tracepoints_category_wild.ll index 6ef345b6a..6e5a70f41 100644 --- a/tests/codegen/llvm/args_multiple_tracepoints_category_wild.ll +++ b/tests/codegen/llvm/args_multiple_tracepoints_category_wild.ll @@ -15,10 +15,9 @@ target triple = "bpf-pc-linux" ; Function Attrs: nounwind declare i64 @llvm.bpf.pseudo(i64 %0, i64 %1) #0 -define i64 @tracepoint_sched_sched_one_1(i8* %0) section "s_tracepoint_sched_sched_one_1" !dbg !55 { +define i64 @tracepoint_sched_sched_one_1(i8* %0) section "s_tracepoint_sched_sched_one_1" !dbg !51 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 + %"@_val" = alloca i64, align 8 %"@_key" = alloca i64, align 8 %1 = ptrtoint i8* %0 to i64 %2 = add i64 %1, 8 @@ -27,33 +26,14 @@ entry: %5 = bitcast i64* %"@_key" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %5) store i64 %4, i64* %"@_key", align 8 - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, i64*)*)(%"struct map_t"* @AT_, i64* %"@_key") - %6 = bitcast i64* %lookup_elem_val to i8* + %6 = bitcast i64* %"@_val" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %6) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - -lookup_success: ; preds = %entry - %cast = bitcast i8* %lookup_elem to i64* - %7 = load i64, i64* %cast, align 8 - %8 = add i64 %7, 1 - store i64 %8, i64* %cast, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %entry - %9 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %9) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %initial_value, i64 1) - %10 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %10) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %11 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %11) - %12 = bitcast i64* %"@_key" to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %12) + store i64 1, i64* %"@_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %"@_val", i64 0) + %7 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %7) + %8 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %8) ret i64 1 } @@ -63,10 +43,9 @@ declare void @llvm.lifetime.start.p0i8(i64 immarg %0, i8* nocapture %1) #1 ; Function Attrs: argmemonly nofree nosync nounwind willreturn declare void @llvm.lifetime.end.p0i8(i64 immarg %0, i8* nocapture %1) #1 -define i64 @tracepoint_sched_sched_two_1(i8* %0) section "s_tracepoint_sched_sched_two_1" !dbg !62 { +define i64 @tracepoint_sched_sched_two_1(i8* %0) section "s_tracepoint_sched_sched_two_1" !dbg !58 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 + %"@_val" = alloca i64, align 8 %"@_key" = alloca i64, align 8 %1 = ptrtoint i8* %0 to i64 %2 = add i64 %1, 16 @@ -75,40 +54,20 @@ entry: %5 = bitcast i64* %"@_key" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %5) store i64 %4, i64* %"@_key", align 8 - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, i64*)*)(%"struct map_t"* @AT_, i64* %"@_key") - %6 = bitcast i64* %lookup_elem_val to i8* + %6 = bitcast i64* %"@_val" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %6) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - -lookup_success: ; preds = %entry - %cast = bitcast i8* %lookup_elem to i64* - %7 = load i64, i64* %cast, align 8 - %8 = add i64 %7, 1 - store i64 %8, i64* %cast, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %entry - %9 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %9) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %initial_value, i64 1) - %10 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %10) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %11 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %11) - %12 = bitcast i64* %"@_key" to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %12) + store i64 1, i64* %"@_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %"@_val", i64 0) + %7 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %7) + %8 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %8) ret i64 1 } -define i64 @tracepoint_sched_extra_sched_extra_1(i8* %0) section "s_tracepoint_sched_extra_sched_extra_1" !dbg !65 { +define i64 @tracepoint_sched_extra_sched_extra_1(i8* %0) section "s_tracepoint_sched_extra_sched_extra_1" !dbg !61 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 + %"@_val" = alloca i64, align 8 %"@_key" = alloca i64, align 8 %1 = ptrtoint i8* %0 to i64 %2 = add i64 %1, 24 @@ -117,41 +76,22 @@ entry: %5 = bitcast i64* %"@_key" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %5) store i64 %4, i64* %"@_key", align 8 - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, i64*)*)(%"struct map_t"* @AT_, i64* %"@_key") - %6 = bitcast i64* %lookup_elem_val to i8* + %6 = bitcast i64* %"@_val" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %6) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - -lookup_success: ; preds = %entry - %cast = bitcast i8* %lookup_elem to i64* - %7 = load i64, i64* %cast, align 8 - %8 = add i64 %7, 1 - store i64 %8, i64* %cast, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %entry - %9 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %9) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %initial_value, i64 1) - %10 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %10) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %11 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %11) - %12 = bitcast i64* %"@_key" to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %12) + store i64 1, i64* %"@_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %"@_val", i64 0) + %7 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %7) + %8 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %8) ret i64 1 } attributes #0 = { nounwind } attributes #1 = { argmemonly nofree nosync nounwind willreturn } -!llvm.dbg.cu = !{!51} -!llvm.module.flags = !{!54} +!llvm.dbg.cu = !{!47} +!llvm.module.flags = !{!50} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "AT_", linkageName: "global", scope: !2, file: !2, type: !3, isLocal: false, isDefinition: true) @@ -160,10 +100,10 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !4 = !{!5, !11, !16, !19} !5 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !6, size: 64) !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 160, elements: !9) +!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !9) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !9 = !{!10} -!10 = !DISubrange(count: 5, lowerBound: 0) +!10 = !DISubrange(count: 1, lowerBound: 0) !11 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !12, size: 64, offset: 64) !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) !13 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 131072, elements: !14) @@ -190,34 +130,30 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) !35 = distinct !DIGlobalVariable(name: "event_loss_counter", linkageName: "global", scope: !2, file: !2, type: !36, isLocal: false, isDefinition: true) !36 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !37) -!37 = !{!38, !43, !48, !19} +!37 = !{!38, !43, !44, !19} !38 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !39, size: 64) !39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !40, size: 64) !40 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 64, elements: !41) !41 = !{!42} !42 = !DISubrange(count: 2, lowerBound: 0) -!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !44, size: 64, offset: 64) -!44 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !45, size: 64) -!45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !46) -!46 = !{!47} -!47 = !DISubrange(count: 1, lowerBound: 0) -!48 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !49, size: 64, offset: 128) -!49 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !50, size: 64) -!50 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) -!51 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !52, globals: !53) -!52 = !{} -!53 = !{!0, !20, !34} -!54 = !{i32 2, !"Debug Info Version", i32 3} -!55 = distinct !DISubprogram(name: "tracepoint_sched_sched_one_1", linkageName: "tracepoint_sched_sched_one_1", scope: !2, file: !2, type: !56, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !51, retainedNodes: !60) -!56 = !DISubroutineType(types: !57) -!57 = !{!18, !58} -!58 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !59, size: 64) -!59 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) -!60 = !{!61} -!61 = !DILocalVariable(name: "ctx", arg: 1, scope: !55, file: !2, type: !58) -!62 = distinct !DISubprogram(name: "tracepoint_sched_sched_two_1", linkageName: "tracepoint_sched_sched_two_1", scope: !2, file: !2, type: !56, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !51, retainedNodes: !63) -!63 = !{!64} -!64 = !DILocalVariable(name: "ctx", arg: 1, scope: !62, file: !2, type: !58) -!65 = distinct !DISubprogram(name: "tracepoint_sched_extra_sched_extra_1", linkageName: "tracepoint_sched_extra_sched_extra_1", scope: !2, file: !2, type: !56, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !51, retainedNodes: !66) -!66 = !{!67} -!67 = !DILocalVariable(name: "ctx", arg: 1, scope: !65, file: !2, type: !58) +!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !6, size: 64, offset: 64) +!44 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !45, size: 64, offset: 128) +!45 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !46, size: 64) +!46 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) +!47 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !48, globals: !49) +!48 = !{} +!49 = !{!0, !20, !34} +!50 = !{i32 2, !"Debug Info Version", i32 3} +!51 = distinct !DISubprogram(name: "tracepoint_sched_sched_one_1", linkageName: "tracepoint_sched_sched_one_1", scope: !2, file: !2, type: !52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !56) +!52 = !DISubroutineType(types: !53) +!53 = !{!18, !54} +!54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !55, size: 64) +!55 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) +!56 = !{!57} +!57 = !DILocalVariable(name: "ctx", arg: 1, scope: !51, file: !2, type: !54) +!58 = distinct !DISubprogram(name: "tracepoint_sched_sched_two_1", linkageName: "tracepoint_sched_sched_two_1", scope: !2, file: !2, type: !52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !59) +!59 = !{!60} +!60 = !DILocalVariable(name: "ctx", arg: 1, scope: !58, file: !2, type: !54) +!61 = distinct !DISubprogram(name: "tracepoint_sched_extra_sched_extra_1", linkageName: "tracepoint_sched_extra_sched_extra_1", scope: !2, file: !2, type: !52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !62) +!62 = !{!63} +!63 = !DILocalVariable(name: "ctx", arg: 1, scope: !61, file: !2, type: !54) diff --git a/tests/codegen/llvm/args_multiple_tracepoints_wild.ll b/tests/codegen/llvm/args_multiple_tracepoints_wild.ll index a9961bf11..06667f06f 100644 --- a/tests/codegen/llvm/args_multiple_tracepoints_wild.ll +++ b/tests/codegen/llvm/args_multiple_tracepoints_wild.ll @@ -15,10 +15,9 @@ target triple = "bpf-pc-linux" ; Function Attrs: nounwind declare i64 @llvm.bpf.pseudo(i64 %0, i64 %1) #0 -define i64 @tracepoint_sched_sched_one_1(i8* %0) section "s_tracepoint_sched_sched_one_1" !dbg !55 { +define i64 @tracepoint_sched_sched_one_1(i8* %0) section "s_tracepoint_sched_sched_one_1" !dbg !51 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 + %"@_val" = alloca i64, align 8 %"@_key" = alloca i64, align 8 %1 = ptrtoint i8* %0 to i64 %2 = add i64 %1, 8 @@ -27,33 +26,14 @@ entry: %5 = bitcast i64* %"@_key" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %5) store i64 %4, i64* %"@_key", align 8 - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, i64*)*)(%"struct map_t"* @AT_, i64* %"@_key") - %6 = bitcast i64* %lookup_elem_val to i8* + %6 = bitcast i64* %"@_val" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %6) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - -lookup_success: ; preds = %entry - %cast = bitcast i8* %lookup_elem to i64* - %7 = load i64, i64* %cast, align 8 - %8 = add i64 %7, 1 - store i64 %8, i64* %cast, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %entry - %9 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %9) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %initial_value, i64 1) - %10 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %10) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %11 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %11) - %12 = bitcast i64* %"@_key" to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %12) + store i64 1, i64* %"@_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %"@_val", i64 0) + %7 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %7) + %8 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %8) ret i64 1 } @@ -63,10 +43,9 @@ declare void @llvm.lifetime.start.p0i8(i64 immarg %0, i8* nocapture %1) #1 ; Function Attrs: argmemonly nofree nosync nounwind willreturn declare void @llvm.lifetime.end.p0i8(i64 immarg %0, i8* nocapture %1) #1 -define i64 @tracepoint_sched_sched_two_1(i8* %0) section "s_tracepoint_sched_sched_two_1" !dbg !62 { +define i64 @tracepoint_sched_sched_two_1(i8* %0) section "s_tracepoint_sched_sched_two_1" !dbg !58 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 + %"@_val" = alloca i64, align 8 %"@_key" = alloca i64, align 8 %1 = ptrtoint i8* %0 to i64 %2 = add i64 %1, 16 @@ -75,41 +54,22 @@ entry: %5 = bitcast i64* %"@_key" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %5) store i64 %4, i64* %"@_key", align 8 - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, i64*)*)(%"struct map_t"* @AT_, i64* %"@_key") - %6 = bitcast i64* %lookup_elem_val to i8* + %6 = bitcast i64* %"@_val" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %6) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - -lookup_success: ; preds = %entry - %cast = bitcast i8* %lookup_elem to i64* - %7 = load i64, i64* %cast, align 8 - %8 = add i64 %7, 1 - store i64 %8, i64* %cast, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %entry - %9 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %9) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %initial_value, i64 1) - %10 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %10) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %11 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %11) - %12 = bitcast i64* %"@_key" to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %12) + store i64 1, i64* %"@_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %"@_val", i64 0) + %7 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %7) + %8 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %8) ret i64 1 } attributes #0 = { nounwind } attributes #1 = { argmemonly nofree nosync nounwind willreturn } -!llvm.dbg.cu = !{!51} -!llvm.module.flags = !{!54} +!llvm.dbg.cu = !{!47} +!llvm.module.flags = !{!50} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "AT_", linkageName: "global", scope: !2, file: !2, type: !3, isLocal: false, isDefinition: true) @@ -118,10 +78,10 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !4 = !{!5, !11, !16, !19} !5 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !6, size: 64) !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 160, elements: !9) +!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !9) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !9 = !{!10} -!10 = !DISubrange(count: 5, lowerBound: 0) +!10 = !DISubrange(count: 1, lowerBound: 0) !11 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !12, size: 64, offset: 64) !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) !13 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 131072, elements: !14) @@ -148,31 +108,27 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) !35 = distinct !DIGlobalVariable(name: "event_loss_counter", linkageName: "global", scope: !2, file: !2, type: !36, isLocal: false, isDefinition: true) !36 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !37) -!37 = !{!38, !43, !48, !19} +!37 = !{!38, !43, !44, !19} !38 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !39, size: 64) !39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !40, size: 64) !40 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 64, elements: !41) !41 = !{!42} !42 = !DISubrange(count: 2, lowerBound: 0) -!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !44, size: 64, offset: 64) -!44 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !45, size: 64) -!45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !46) -!46 = !{!47} -!47 = !DISubrange(count: 1, lowerBound: 0) -!48 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !49, size: 64, offset: 128) -!49 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !50, size: 64) -!50 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) -!51 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !52, globals: !53) -!52 = !{} -!53 = !{!0, !20, !34} -!54 = !{i32 2, !"Debug Info Version", i32 3} -!55 = distinct !DISubprogram(name: "tracepoint_sched_sched_one_1", linkageName: "tracepoint_sched_sched_one_1", scope: !2, file: !2, type: !56, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !51, retainedNodes: !60) -!56 = !DISubroutineType(types: !57) -!57 = !{!18, !58} -!58 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !59, size: 64) -!59 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) -!60 = !{!61} -!61 = !DILocalVariable(name: "ctx", arg: 1, scope: !55, file: !2, type: !58) -!62 = distinct !DISubprogram(name: "tracepoint_sched_sched_two_1", linkageName: "tracepoint_sched_sched_two_1", scope: !2, file: !2, type: !56, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !51, retainedNodes: !63) -!63 = !{!64} -!64 = !DILocalVariable(name: "ctx", arg: 1, scope: !62, file: !2, type: !58) +!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !6, size: 64, offset: 64) +!44 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !45, size: 64, offset: 128) +!45 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !46, size: 64) +!46 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) +!47 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !48, globals: !49) +!48 = !{} +!49 = !{!0, !20, !34} +!50 = !{i32 2, !"Debug Info Version", i32 3} +!51 = distinct !DISubprogram(name: "tracepoint_sched_sched_one_1", linkageName: "tracepoint_sched_sched_one_1", scope: !2, file: !2, type: !52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !56) +!52 = !DISubroutineType(types: !53) +!53 = !{!18, !54} +!54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !55, size: 64) +!55 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) +!56 = !{!57} +!57 = !DILocalVariable(name: "ctx", arg: 1, scope: !51, file: !2, type: !54) +!58 = distinct !DISubprogram(name: "tracepoint_sched_sched_two_1", linkageName: "tracepoint_sched_sched_two_1", scope: !2, file: !2, type: !52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !59) +!59 = !{!60} +!60 = !DILocalVariable(name: "ctx", arg: 1, scope: !58, file: !2, type: !54) diff --git a/tests/codegen/llvm/call_ntop_key.ll b/tests/codegen/llvm/call_ntop_key.ll index 3735fef28..e6495664f 100644 --- a/tests/codegen/llvm/call_ntop_key.ll +++ b/tests/codegen/llvm/call_ntop_key.ll @@ -16,10 +16,9 @@ target triple = "bpf-pc-linux" ; Function Attrs: nounwind declare i64 @llvm.bpf.pseudo(i64 %0, i64 %1) #0 -define i64 @kprobe_f_1(i8* %0) section "s_kprobe_f_1" !dbg !60 { +define i64 @kprobe_f_1(i8* %0) section "s_kprobe_f_1" !dbg !56 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 + %"@x_val" = alloca i64, align 8 %inet = alloca %inet_t, align 8 %1 = bitcast %inet_t* %inet to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %1) @@ -30,31 +29,12 @@ entry: call void @llvm.memset.p0i8.i64(i8* align 1 %4, i8 0, i64 16, i1 false) %5 = bitcast [16 x i8]* %3 to i32* store i32 -1, i32* %5, align 4 - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, %inet_t*)*)(%"struct map_t"* @AT_x, %inet_t* %inet) - %6 = bitcast i64* %lookup_elem_val to i8* + %6 = bitcast i64* %"@x_val" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %6) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - -lookup_success: ; preds = %entry - %cast = bitcast i8* %lookup_elem to i64* - %7 = load i64, i64* %cast, align 8 - %8 = add i64 %7, 1 - store i64 %8, i64* %cast, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %entry - %9 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %9) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, %inet_t*, i64*, i64)*)(%"struct map_t"* @AT_x, %inet_t* %inet, i64* %initial_value, i64 1) - %10 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %10) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %11 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %11) + store i64 1, i64* %"@x_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, %inet_t*, i64*, i64)*)(%"struct map_t"* @AT_x, %inet_t* %inet, i64* %"@x_val", i64 0) + %7 = bitcast i64* %"@x_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %7) ret i64 0 } @@ -71,8 +51,8 @@ attributes #0 = { nounwind } attributes #1 = { argmemonly nofree nosync nounwind willreturn } attributes #2 = { argmemonly nofree nosync nounwind willreturn writeonly } -!llvm.dbg.cu = !{!56} -!llvm.module.flags = !{!59} +!llvm.dbg.cu = !{!52} +!llvm.module.flags = !{!55} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "AT_x", linkageName: "global", scope: !2, file: !2, type: !3, isLocal: false, isDefinition: true) @@ -81,10 +61,10 @@ attributes #2 = { argmemonly nofree nosync nounwind willreturn writeonly } !4 = !{!5, !11, !16, !22} !5 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !6, size: 64) !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 160, elements: !9) +!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !9) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !9 = !{!10} -!10 = !DISubrange(count: 5, lowerBound: 0) +!10 = !DISubrange(count: 1, lowerBound: 0) !11 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !12, size: 64, offset: 64) !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) !13 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 131072, elements: !14) @@ -116,27 +96,23 @@ attributes #2 = { argmemonly nofree nosync nounwind willreturn writeonly } !39 = !DIGlobalVariableExpression(var: !40, expr: !DIExpression()) !40 = distinct !DIGlobalVariable(name: "event_loss_counter", linkageName: "global", scope: !2, file: !2, type: !41, isLocal: false, isDefinition: true) !41 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !42) -!42 = !{!43, !48, !53, !22} +!42 = !{!43, !48, !49, !22} !43 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !44, size: 64) !44 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !45, size: 64) !45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 64, elements: !46) !46 = !{!47} !47 = !DISubrange(count: 2, lowerBound: 0) -!48 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !49, size: 64, offset: 64) -!49 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !50, size: 64) -!50 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !51) -!51 = !{!52} -!52 = !DISubrange(count: 1, lowerBound: 0) -!53 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !54, size: 64, offset: 128) -!54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !55, size: 64) -!55 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) -!56 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !57, globals: !58) -!57 = !{} -!58 = !{!0, !25, !39} -!59 = !{i32 2, !"Debug Info Version", i32 3} -!60 = distinct !DISubprogram(name: "kprobe_f_1", linkageName: "kprobe_f_1", scope: !2, file: !2, type: !61, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !56, retainedNodes: !64) -!61 = !DISubroutineType(types: !62) -!62 = !{!24, !63} -!63 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64) -!64 = !{!65} -!65 = !DILocalVariable(name: "ctx", arg: 1, scope: !60, file: !2, type: !63) +!48 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !6, size: 64, offset: 64) +!49 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !50, size: 64, offset: 128) +!50 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !51, size: 64) +!51 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) +!52 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !53, globals: !54) +!53 = !{} +!54 = !{!0, !25, !39} +!55 = !{i32 2, !"Debug Info Version", i32 3} +!56 = distinct !DISubprogram(name: "kprobe_f_1", linkageName: "kprobe_f_1", scope: !2, file: !2, type: !57, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !52, retainedNodes: !60) +!57 = !DISubroutineType(types: !58) +!58 = !{!24, !59} +!59 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64) +!60 = !{!61} +!61 = !DILocalVariable(name: "ctx", arg: 1, scope: !56, file: !2, type: !59) diff --git a/tests/codegen/llvm/call_usym_key.ll b/tests/codegen/llvm/call_usym_key.ll index 0abeed254..0e01dde82 100644 --- a/tests/codegen/llvm/call_usym_key.ll +++ b/tests/codegen/llvm/call_usym_key.ll @@ -16,10 +16,9 @@ target triple = "bpf-pc-linux" ; Function Attrs: nounwind declare i64 @llvm.bpf.pseudo(i64 %0, i64 %1) #0 -define i64 @kprobe_f_1(i8* %0) section "s_kprobe_f_1" !dbg !60 { +define i64 @kprobe_f_1(i8* %0) section "s_kprobe_f_1" !dbg !56 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 + %"@x_val" = alloca i64, align 8 %usym = alloca %usym_t, align 8 %1 = bitcast %usym_t* %usym to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %1) @@ -31,31 +30,12 @@ entry: store i64 0, i64* %3, align 8 store i64 %2, i64* %4, align 8 store i64 0, i64* %5, align 8 - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, %usym_t*)*)(%"struct map_t"* @AT_x, %usym_t* %usym) - %6 = bitcast i64* %lookup_elem_val to i8* + %6 = bitcast i64* %"@x_val" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %6) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - -lookup_success: ; preds = %entry - %cast = bitcast i8* %lookup_elem to i64* - %7 = load i64, i64* %cast, align 8 - %8 = add i64 %7, 1 - store i64 %8, i64* %cast, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %entry - %9 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %9) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, %usym_t*, i64*, i64)*)(%"struct map_t"* @AT_x, %usym_t* %usym, i64* %initial_value, i64 1) - %10 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %10) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %11 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %11) + store i64 1, i64* %"@x_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, %usym_t*, i64*, i64)*)(%"struct map_t"* @AT_x, %usym_t* %usym, i64* %"@x_val", i64 0) + %7 = bitcast i64* %"@x_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %7) ret i64 0 } @@ -68,8 +48,8 @@ declare void @llvm.lifetime.end.p0i8(i64 immarg %0, i8* nocapture %1) #1 attributes #0 = { nounwind } attributes #1 = { argmemonly nofree nosync nounwind willreturn } -!llvm.dbg.cu = !{!56} -!llvm.module.flags = !{!59} +!llvm.dbg.cu = !{!52} +!llvm.module.flags = !{!55} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "AT_x", linkageName: "global", scope: !2, file: !2, type: !3, isLocal: false, isDefinition: true) @@ -78,10 +58,10 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !4 = !{!5, !11, !16, !22} !5 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !6, size: 64) !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 160, elements: !9) +!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !9) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !9 = !{!10} -!10 = !DISubrange(count: 5, lowerBound: 0) +!10 = !DISubrange(count: 1, lowerBound: 0) !11 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !12, size: 64, offset: 64) !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) !13 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 131072, elements: !14) @@ -113,27 +93,23 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !39 = !DIGlobalVariableExpression(var: !40, expr: !DIExpression()) !40 = distinct !DIGlobalVariable(name: "event_loss_counter", linkageName: "global", scope: !2, file: !2, type: !41, isLocal: false, isDefinition: true) !41 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !42) -!42 = !{!43, !48, !53, !22} +!42 = !{!43, !48, !49, !22} !43 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !44, size: 64) !44 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !45, size: 64) !45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 64, elements: !46) !46 = !{!47} !47 = !DISubrange(count: 2, lowerBound: 0) -!48 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !49, size: 64, offset: 64) -!49 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !50, size: 64) -!50 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !51) -!51 = !{!52} -!52 = !DISubrange(count: 1, lowerBound: 0) -!53 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !54, size: 64, offset: 128) -!54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !55, size: 64) -!55 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) -!56 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !57, globals: !58) -!57 = !{} -!58 = !{!0, !25, !39} -!59 = !{i32 2, !"Debug Info Version", i32 3} -!60 = distinct !DISubprogram(name: "kprobe_f_1", linkageName: "kprobe_f_1", scope: !2, file: !2, type: !61, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !56, retainedNodes: !64) -!61 = !DISubroutineType(types: !62) -!62 = !{!24, !63} -!63 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64) -!64 = !{!65} -!65 = !DILocalVariable(name: "ctx", arg: 1, scope: !60, file: !2, type: !63) +!48 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !6, size: 64, offset: 64) +!49 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !50, size: 64, offset: 128) +!50 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !51, size: 64) +!51 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) +!52 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !53, globals: !54) +!53 = !{} +!54 = !{!0, !25, !39} +!55 = !{i32 2, !"Debug Info Version", i32 3} +!56 = distinct !DISubprogram(name: "kprobe_f_1", linkageName: "kprobe_f_1", scope: !2, file: !2, type: !57, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !52, retainedNodes: !60) +!57 = !DISubroutineType(types: !58) +!58 = !{!24, !59} +!59 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64) +!60 = !{!61} +!61 = !DILocalVariable(name: "ctx", arg: 1, scope: !56, file: !2, type: !59) diff --git a/tests/codegen/llvm/iter_dereference.ll b/tests/codegen/llvm/iter_dereference.ll index 232878b6d..1f0ce7e3d 100644 --- a/tests/codegen/llvm/iter_dereference.ll +++ b/tests/codegen/llvm/iter_dereference.ll @@ -15,10 +15,9 @@ target triple = "bpf-pc-linux" ; Function Attrs: nounwind declare i64 @llvm.bpf.pseudo(i64 %0, i64 %1) #0 -define i64 @iter_task_file_1(i8* %0) section "s_iter_task_file_1" !dbg !55 { +define i64 @iter_task_file_1(i8* %0) section "s_iter_task_file_1" !dbg !51 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 + %"@_val" = alloca i64, align 8 %"@_key" = alloca i64, align 8 %1 = ptrtoint i8* %0 to i64 %2 = add i64 %1, 0 @@ -37,33 +36,14 @@ pred_true: ; preds = %entry %8 = bitcast i64* %"@_key" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %8) store i64 %7, i64* %"@_key", align 8 - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, i64*)*)(%"struct map_t"* @AT_, i64* %"@_key") - %9 = bitcast i64* %lookup_elem_val to i8* + %9 = bitcast i64* %"@_val" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %9) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - -lookup_success: ; preds = %pred_true - %cast = bitcast i8* %lookup_elem to i64* - %10 = load i64, i64* %cast, align 8 - %11 = add i64 %10, 1 - store i64 %11, i64* %cast, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %pred_true - %12 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %12) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %initial_value, i64 1) - %13 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %13) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %14 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %14) - %15 = bitcast i64* %"@_key" to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %15) + store i64 1, i64* %"@_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %"@_val", i64 0) + %10 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %10) + %11 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %11) ret i64 0 } @@ -76,8 +56,8 @@ declare void @llvm.lifetime.end.p0i8(i64 immarg %0, i8* nocapture %1) #1 attributes #0 = { nounwind } attributes #1 = { argmemonly nofree nosync nounwind willreturn } -!llvm.dbg.cu = !{!51} -!llvm.module.flags = !{!54} +!llvm.dbg.cu = !{!47} +!llvm.module.flags = !{!50} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "AT_", linkageName: "global", scope: !2, file: !2, type: !3, isLocal: false, isDefinition: true) @@ -86,10 +66,10 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !4 = !{!5, !11, !16, !19} !5 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !6, size: 64) !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 160, elements: !9) +!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !9) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !9 = !{!10} -!10 = !DISubrange(count: 5, lowerBound: 0) +!10 = !DISubrange(count: 1, lowerBound: 0) !11 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !12, size: 64, offset: 64) !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) !13 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 131072, elements: !14) @@ -116,28 +96,24 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) !35 = distinct !DIGlobalVariable(name: "event_loss_counter", linkageName: "global", scope: !2, file: !2, type: !36, isLocal: false, isDefinition: true) !36 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !37) -!37 = !{!38, !43, !48, !19} +!37 = !{!38, !43, !44, !19} !38 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !39, size: 64) !39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !40, size: 64) !40 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 64, elements: !41) !41 = !{!42} !42 = !DISubrange(count: 2, lowerBound: 0) -!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !44, size: 64, offset: 64) -!44 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !45, size: 64) -!45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !46) -!46 = !{!47} -!47 = !DISubrange(count: 1, lowerBound: 0) -!48 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !49, size: 64, offset: 128) -!49 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !50, size: 64) -!50 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) -!51 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !52, globals: !53) -!52 = !{} -!53 = !{!0, !20, !34} -!54 = !{i32 2, !"Debug Info Version", i32 3} -!55 = distinct !DISubprogram(name: "iter_task_file_1", linkageName: "iter_task_file_1", scope: !2, file: !2, type: !56, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !51, retainedNodes: !60) -!56 = !DISubroutineType(types: !57) -!57 = !{!18, !58} -!58 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !59, size: 64) -!59 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) -!60 = !{!61} -!61 = !DILocalVariable(name: "ctx", arg: 1, scope: !55, file: !2, type: !58) +!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !6, size: 64, offset: 64) +!44 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !45, size: 64, offset: 128) +!45 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !46, size: 64) +!46 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) +!47 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !48, globals: !49) +!48 = !{} +!49 = !{!0, !20, !34} +!50 = !{i32 2, !"Debug Info Version", i32 3} +!51 = distinct !DISubprogram(name: "iter_task_file_1", linkageName: "iter_task_file_1", scope: !2, file: !2, type: !52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !56) +!52 = !DISubroutineType(types: !53) +!53 = !{!18, !54} +!54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !55, size: 64) +!55 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) +!56 = !{!57} +!57 = !DILocalVariable(name: "ctx", arg: 1, scope: !51, file: !2, type: !54) diff --git a/tests/codegen/llvm/kfunc_dereference.ll b/tests/codegen/llvm/kfunc_dereference.ll index 7e34fd1d1..23cd5b13e 100644 --- a/tests/codegen/llvm/kfunc_dereference.ll +++ b/tests/codegen/llvm/kfunc_dereference.ll @@ -15,10 +15,9 @@ target triple = "bpf-pc-linux" ; Function Attrs: nounwind declare i64 @llvm.bpf.pseudo(i64 %0, i64 %1) #0 -define i64 @kfunc_mock_vmlinux_tcp_sendmsg_1(i8* %0) section "s_kfunc_mock_vmlinux_tcp_sendmsg_1" !dbg !55 { +define i64 @kfunc_mock_vmlinux_tcp_sendmsg_1(i8* %0) section "s_kfunc_mock_vmlinux_tcp_sendmsg_1" !dbg !51 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 + %"@_val" = alloca i64, align 8 %"@_key" = alloca i64, align 8 %1 = ptrtoint i8* %0 to i64 %2 = bitcast i8* %0 to i64* @@ -32,33 +31,14 @@ entry: %8 = bitcast i64* %"@_key" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %8) store i64 %cast, i64* %"@_key", align 8 - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, i64*)*)(%"struct map_t"* @AT_, i64* %"@_key") - %9 = bitcast i64* %lookup_elem_val to i8* + %9 = bitcast i64* %"@_val" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %9) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - -lookup_success: ; preds = %entry - %cast1 = bitcast i8* %lookup_elem to i64* - %10 = load i64, i64* %cast1, align 8 - %11 = add i64 %10, 1 - store i64 %11, i64* %cast1, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %entry - %12 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %12) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %initial_value, i64 1) - %13 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %13) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %14 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %14) - %15 = bitcast i64* %"@_key" to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %15) + store i64 1, i64* %"@_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %"@_val", i64 0) + %10 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %10) + %11 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %11) ret i64 0 } @@ -71,8 +51,8 @@ declare void @llvm.lifetime.end.p0i8(i64 immarg %0, i8* nocapture %1) #1 attributes #0 = { nounwind } attributes #1 = { argmemonly nofree nosync nounwind willreturn } -!llvm.dbg.cu = !{!51} -!llvm.module.flags = !{!54} +!llvm.dbg.cu = !{!47} +!llvm.module.flags = !{!50} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "AT_", linkageName: "global", scope: !2, file: !2, type: !3, isLocal: false, isDefinition: true) @@ -81,10 +61,10 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !4 = !{!5, !11, !16, !19} !5 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !6, size: 64) !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 160, elements: !9) +!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !9) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !9 = !{!10} -!10 = !DISubrange(count: 5, lowerBound: 0) +!10 = !DISubrange(count: 1, lowerBound: 0) !11 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !12, size: 64, offset: 64) !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) !13 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 131072, elements: !14) @@ -111,28 +91,24 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) !35 = distinct !DIGlobalVariable(name: "event_loss_counter", linkageName: "global", scope: !2, file: !2, type: !36, isLocal: false, isDefinition: true) !36 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !37) -!37 = !{!38, !43, !48, !19} +!37 = !{!38, !43, !44, !19} !38 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !39, size: 64) !39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !40, size: 64) !40 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 64, elements: !41) !41 = !{!42} !42 = !DISubrange(count: 2, lowerBound: 0) -!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !44, size: 64, offset: 64) -!44 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !45, size: 64) -!45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !46) -!46 = !{!47} -!47 = !DISubrange(count: 1, lowerBound: 0) -!48 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !49, size: 64, offset: 128) -!49 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !50, size: 64) -!50 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) -!51 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !52, globals: !53) -!52 = !{} -!53 = !{!0, !20, !34} -!54 = !{i32 2, !"Debug Info Version", i32 3} -!55 = distinct !DISubprogram(name: "kfunc_mock_vmlinux_tcp_sendmsg_1", linkageName: "kfunc_mock_vmlinux_tcp_sendmsg_1", scope: !2, file: !2, type: !56, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !51, retainedNodes: !60) -!56 = !DISubroutineType(types: !57) -!57 = !{!18, !58} -!58 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !59, size: 64) -!59 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) -!60 = !{!61} -!61 = !DILocalVariable(name: "ctx", arg: 1, scope: !55, file: !2, type: !58) +!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !6, size: 64, offset: 64) +!44 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !45, size: 64, offset: 128) +!45 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !46, size: 64) +!46 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) +!47 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !48, globals: !49) +!48 = !{} +!49 = !{!0, !20, !34} +!50 = !{i32 2, !"Debug Info Version", i32 3} +!51 = distinct !DISubprogram(name: "kfunc_mock_vmlinux_tcp_sendmsg_1", linkageName: "kfunc_mock_vmlinux_tcp_sendmsg_1", scope: !2, file: !2, type: !52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !56) +!52 = !DISubroutineType(types: !53) +!53 = !{!18, !54} +!54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !55, size: 64) +!55 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) +!56 = !{!57} +!57 = !DILocalVariable(name: "ctx", arg: 1, scope: !51, file: !2, type: !54) diff --git a/tests/codegen/llvm/kretfunc_dereference.ll b/tests/codegen/llvm/kretfunc_dereference.ll index dafee177f..e58266d5c 100644 --- a/tests/codegen/llvm/kretfunc_dereference.ll +++ b/tests/codegen/llvm/kretfunc_dereference.ll @@ -15,10 +15,9 @@ target triple = "bpf-pc-linux" ; Function Attrs: nounwind declare i64 @llvm.bpf.pseudo(i64 %0, i64 %1) #0 -define i64 @kretfunc_mock_vmlinux_sk_alloc_1(i8* %0) section "s_kretfunc_mock_vmlinux_sk_alloc_1" !dbg !55 { +define i64 @kretfunc_mock_vmlinux_sk_alloc_1(i8* %0) section "s_kretfunc_mock_vmlinux_sk_alloc_1" !dbg !51 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 + %"@_val" = alloca i64, align 8 %"@_key" = alloca i64, align 8 %1 = bitcast i8* %0 to i64* %2 = getelementptr i64, i64* %1, i64 5 @@ -31,33 +30,14 @@ entry: %7 = bitcast i64* %"@_key" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %7) store i64 %cast, i64* %"@_key", align 8 - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, i64*)*)(%"struct map_t"* @AT_, i64* %"@_key") - %8 = bitcast i64* %lookup_elem_val to i8* + %8 = bitcast i64* %"@_val" to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* %8) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - -lookup_success: ; preds = %entry - %cast1 = bitcast i8* %lookup_elem to i64* - %9 = load i64, i64* %cast1, align 8 - %10 = add i64 %9, 1 - store i64 %10, i64* %cast1, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %entry - %11 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %11) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %initial_value, i64 1) - %12 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %12) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %13 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %13) - %14 = bitcast i64* %"@_key" to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %14) + store i64 1, i64* %"@_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %"@_val", i64 0) + %9 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %9) + %10 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %10) ret i64 0 } @@ -70,8 +50,8 @@ declare void @llvm.lifetime.end.p0i8(i64 immarg %0, i8* nocapture %1) #1 attributes #0 = { nounwind } attributes #1 = { argmemonly nofree nosync nounwind willreturn } -!llvm.dbg.cu = !{!51} -!llvm.module.flags = !{!54} +!llvm.dbg.cu = !{!47} +!llvm.module.flags = !{!50} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "AT_", linkageName: "global", scope: !2, file: !2, type: !3, isLocal: false, isDefinition: true) @@ -80,10 +60,10 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !4 = !{!5, !11, !16, !19} !5 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !6, size: 64) !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 160, elements: !9) +!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !9) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !9 = !{!10} -!10 = !DISubrange(count: 5, lowerBound: 0) +!10 = !DISubrange(count: 1, lowerBound: 0) !11 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !12, size: 64, offset: 64) !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) !13 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 131072, elements: !14) @@ -110,28 +90,24 @@ attributes #1 = { argmemonly nofree nosync nounwind willreturn } !34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) !35 = distinct !DIGlobalVariable(name: "event_loss_counter", linkageName: "global", scope: !2, file: !2, type: !36, isLocal: false, isDefinition: true) !36 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !37) -!37 = !{!38, !43, !48, !19} +!37 = !{!38, !43, !44, !19} !38 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !39, size: 64) !39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !40, size: 64) !40 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 64, elements: !41) !41 = !{!42} !42 = !DISubrange(count: 2, lowerBound: 0) -!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !44, size: 64, offset: 64) -!44 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !45, size: 64) -!45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !46) -!46 = !{!47} -!47 = !DISubrange(count: 1, lowerBound: 0) -!48 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !49, size: 64, offset: 128) -!49 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !50, size: 64) -!50 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) -!51 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !52, globals: !53) -!52 = !{} -!53 = !{!0, !20, !34} -!54 = !{i32 2, !"Debug Info Version", i32 3} -!55 = distinct !DISubprogram(name: "kretfunc_mock_vmlinux_sk_alloc_1", linkageName: "kretfunc_mock_vmlinux_sk_alloc_1", scope: !2, file: !2, type: !56, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !51, retainedNodes: !60) -!56 = !DISubroutineType(types: !57) -!57 = !{!18, !58} -!58 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !59, size: 64) -!59 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) -!60 = !{!61} -!61 = !DILocalVariable(name: "ctx", arg: 1, scope: !55, file: !2, type: !58) +!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !6, size: 64, offset: 64) +!44 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !45, size: 64, offset: 128) +!45 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !46, size: 64) +!46 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) +!47 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !48, globals: !49) +!48 = !{} +!49 = !{!0, !20, !34} +!50 = !{i32 2, !"Debug Info Version", i32 3} +!51 = distinct !DISubprogram(name: "kretfunc_mock_vmlinux_sk_alloc_1", linkageName: "kretfunc_mock_vmlinux_sk_alloc_1", scope: !2, file: !2, type: !52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !56) +!52 = !DISubroutineType(types: !53) +!53 = !{!18, !54} +!54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !55, size: 64) +!55 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) +!56 = !{!57} +!57 = !DILocalVariable(name: "ctx", arg: 1, scope: !51, file: !2, type: !54) diff --git a/tests/codegen/llvm/literal_strncmp.ll b/tests/codegen/llvm/literal_strncmp.ll index 8b0aaf114..fa6ce79ae 100644 --- a/tests/codegen/llvm/literal_strncmp.ll +++ b/tests/codegen/llvm/literal_strncmp.ll @@ -9,17 +9,16 @@ target triple = "bpf-pc-linux" @LICENSE = global [4 x i8] c"GPL\00", section "license" @AT_ = dso_local global %"struct map_t" zeroinitializer, section ".maps", !dbg !0 -@ringbuf = dso_local global %"struct map_t.0" zeroinitializer, section ".maps", !dbg !25 -@event_loss_counter = dso_local global %"struct map_t.1" zeroinitializer, section ".maps", !dbg !39 +@ringbuf = dso_local global %"struct map_t.0" zeroinitializer, section ".maps", !dbg !20 +@event_loss_counter = dso_local global %"struct map_t.1" zeroinitializer, section ".maps", !dbg !34 ; Function Attrs: nounwind declare i64 @llvm.bpf.pseudo(i64 %0, i64 %1) #0 -define i64 @kretprobe_vfs_read_1(i8* %0) section "s_kretprobe_vfs_read_1" !dbg !60 { +define i64 @kprobe_f_1(i8* %0) section "s_kprobe_f_1" !dbg !51 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 - %comm5 = alloca [16 x i8], align 1 + %"@_val" = alloca i64, align 8 + %"@_key" = alloca i64, align 8 %strcmp.result = alloca i1, align 1 %comm = alloca [16 x i8], align 1 %1 = bitcast [16 x i8]* %comm to i8* @@ -36,40 +35,35 @@ entry: %strcmp.cmp = icmp ne i8 %6, 115 br i1 %strcmp.cmp, label %strcmp.false, label %strcmp.loop_null_cmp -pred_false: ; preds = %strcmp.false - ret i64 0 - -pred_true: ; preds = %strcmp.false - %7 = bitcast [16 x i8]* %comm to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %7) - %8 = bitcast [16 x i8]* %comm5 to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %8) - %9 = bitcast [16 x i8]* %comm5 to i8* - call void @llvm.memset.p0i8.i64(i8* align 1 %9, i8 0, i64 16, i1 false) - %get_comm6 = call i64 inttoptr (i64 16 to i64 ([16 x i8]*, i64)*)([16 x i8]* %comm5, i64 16) - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, [16 x i8]*)*)(%"struct map_t"* @AT_, [16 x i8]* %comm5) - %10 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %10) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - strcmp.false: ; preds = %strcmp.done, %strcmp.loop, %entry - %11 = load i1, i1* %strcmp.result, align 1 - %12 = bitcast i1* %strcmp.result to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %12) - %13 = zext i1 %11 to i64 - %predcond = icmp eq i64 %13, 0 - br i1 %predcond, label %pred_false, label %pred_true + %7 = load i1, i1* %strcmp.result, align 1 + %8 = bitcast i1* %strcmp.result to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %8) + %9 = zext i1 %7 to i64 + %10 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.start.p0i8(i64 -1, i8* %10) + store i64 %9, i64* %"@_key", align 8 + %11 = bitcast [16 x i8]* %comm to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %11) + %12 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.start.p0i8(i64 -1, i8* %12) + store i64 1, i64* %"@_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %"@_val", i64 0) + %13 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %13) + %14 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %14) + ret i64 0 strcmp.done: ; preds = %strcmp.loop1, %strcmp.loop_null_cmp2, %strcmp.loop_null_cmp store i1 false, i1* %strcmp.result, align 1 br label %strcmp.false strcmp.loop: ; preds = %strcmp.loop_null_cmp - %14 = bitcast [16 x i8]* %comm to i8* - %15 = getelementptr i8, i8* %14, i32 1 - %16 = load i8, i8* %15, align 1 - %strcmp.cmp3 = icmp ne i8 %16, 115 + %15 = bitcast [16 x i8]* %comm to i8* + %16 = getelementptr i8, i8* %15, i32 1 + %17 = load i8, i8* %16, align 1 + %strcmp.cmp3 = icmp ne i8 %17, 115 br i1 %strcmp.cmp3, label %strcmp.false, label %strcmp.loop_null_cmp2 strcmp.loop_null_cmp: ; preds = %entry @@ -80,29 +74,8 @@ strcmp.loop1: ; preds = %strcmp.loop_null_cm br label %strcmp.done strcmp.loop_null_cmp2: ; preds = %strcmp.loop - %strcmp.cmp_null4 = icmp eq i8 %16, 0 + %strcmp.cmp_null4 = icmp eq i8 %17, 0 br i1 %strcmp.cmp_null4, label %strcmp.done, label %strcmp.loop1 - -lookup_success: ; preds = %pred_true - %cast = bitcast i8* %lookup_elem to i64* - %17 = load i64, i64* %cast, align 8 - %18 = add i64 %17, 1 - store i64 %18, i64* %cast, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %pred_true - %19 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %19) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, [16 x i8]*, i64*, i64)*)(%"struct map_t"* @AT_, [16 x i8]* %comm5, i64* %initial_value, i64 1) - %20 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %20) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %21 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %21) - ret i64 0 } ; Function Attrs: argmemonly nofree nosync nounwind willreturn @@ -118,20 +91,20 @@ attributes #0 = { nounwind } attributes #1 = { argmemonly nofree nosync nounwind willreturn } attributes #2 = { argmemonly nofree nosync nounwind willreturn writeonly } -!llvm.dbg.cu = !{!56} -!llvm.module.flags = !{!59} +!llvm.dbg.cu = !{!47} +!llvm.module.flags = !{!50} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "AT_", linkageName: "global", scope: !2, file: !2, type: !3, isLocal: false, isDefinition: true) !2 = !DIFile(filename: "bpftrace.bpf.o", directory: ".") !3 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !4) -!4 = !{!5, !11, !16, !22} +!4 = !{!5, !11, !16, !19} !5 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !6, size: 64) !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 160, elements: !9) +!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !9) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !9 = !{!10} -!10 = !DISubrange(count: 5, lowerBound: 0) +!10 = !DISubrange(count: 1, lowerBound: 0) !11 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !12, size: 64, offset: 64) !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) !13 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 131072, elements: !14) @@ -139,51 +112,43 @@ attributes #2 = { argmemonly nofree nosync nounwind willreturn writeonly } !15 = !DISubrange(count: 4096, lowerBound: 0) !16 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !17, size: 64, offset: 128) !17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !18, size: 64) -!18 = !DICompositeType(tag: DW_TAG_array_type, baseType: !19, size: 128, elements: !20) -!19 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) -!20 = !{!21} -!21 = !DISubrange(count: 16, lowerBound: 0) -!22 = !DIDerivedType(tag: DW_TAG_member, name: "value", scope: !2, file: !2, baseType: !23, size: 64, offset: 192) -!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !24, size: 64) -!24 = !DIBasicType(name: "int64", size: 64, encoding: DW_ATE_signed) -!25 = !DIGlobalVariableExpression(var: !26, expr: !DIExpression()) -!26 = distinct !DIGlobalVariable(name: "ringbuf", linkageName: "global", scope: !2, file: !2, type: !27, isLocal: false, isDefinition: true) -!27 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 128, elements: !28) -!28 = !{!29, !34} -!29 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !30, size: 64) +!18 = !DIBasicType(name: "int64", size: 64, encoding: DW_ATE_signed) +!19 = !DIDerivedType(tag: DW_TAG_member, name: "value", scope: !2, file: !2, baseType: !17, size: 64, offset: 192) +!20 = !DIGlobalVariableExpression(var: !21, expr: !DIExpression()) +!21 = distinct !DIGlobalVariable(name: "ringbuf", linkageName: "global", scope: !2, file: !2, type: !22, isLocal: false, isDefinition: true) +!22 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 128, elements: !23) +!23 = !{!24, !29} +!24 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !25, size: 64) +!25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !26, size: 64) +!26 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 864, elements: !27) +!27 = !{!28} +!28 = !DISubrange(count: 27, lowerBound: 0) +!29 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !30, size: 64, offset: 64) !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !31, size: 64) -!31 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 864, elements: !32) +!31 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 8388608, elements: !32) !32 = !{!33} -!33 = !DISubrange(count: 27, lowerBound: 0) -!34 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !35, size: 64, offset: 64) -!35 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !36, size: 64) -!36 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 8388608, elements: !37) -!37 = !{!38} -!38 = !DISubrange(count: 262144, lowerBound: 0) -!39 = !DIGlobalVariableExpression(var: !40, expr: !DIExpression()) -!40 = distinct !DIGlobalVariable(name: "event_loss_counter", linkageName: "global", scope: !2, file: !2, type: !41, isLocal: false, isDefinition: true) -!41 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !42) -!42 = !{!43, !48, !53, !22} -!43 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !44, size: 64) -!44 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !45, size: 64) -!45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 64, elements: !46) -!46 = !{!47} -!47 = !DISubrange(count: 2, lowerBound: 0) -!48 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !49, size: 64, offset: 64) -!49 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !50, size: 64) -!50 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !51) -!51 = !{!52} -!52 = !DISubrange(count: 1, lowerBound: 0) -!53 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !54, size: 64, offset: 128) +!33 = !DISubrange(count: 262144, lowerBound: 0) +!34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) +!35 = distinct !DIGlobalVariable(name: "event_loss_counter", linkageName: "global", scope: !2, file: !2, type: !36, isLocal: false, isDefinition: true) +!36 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !37) +!37 = !{!38, !43, !44, !19} +!38 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !39, size: 64) +!39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !40, size: 64) +!40 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 64, elements: !41) +!41 = !{!42} +!42 = !DISubrange(count: 2, lowerBound: 0) +!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !6, size: 64, offset: 64) +!44 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !45, size: 64, offset: 128) +!45 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !46, size: 64) +!46 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) +!47 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !48, globals: !49) +!48 = !{} +!49 = !{!0, !20, !34} +!50 = !{i32 2, !"Debug Info Version", i32 3} +!51 = distinct !DISubprogram(name: "kprobe_f_1", linkageName: "kprobe_f_1", scope: !2, file: !2, type: !52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !56) +!52 = !DISubroutineType(types: !53) +!53 = !{!18, !54} !54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !55, size: 64) -!55 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) -!56 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !57, globals: !58) -!57 = !{} -!58 = !{!0, !25, !39} -!59 = !{i32 2, !"Debug Info Version", i32 3} -!60 = distinct !DISubprogram(name: "kretprobe_vfs_read_1", linkageName: "kretprobe_vfs_read_1", scope: !2, file: !2, type: !61, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !56, retainedNodes: !64) -!61 = !DISubroutineType(types: !62) -!62 = !{!24, !63} -!63 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64) -!64 = !{!65} -!65 = !DILocalVariable(name: "ctx", arg: 1, scope: !60, file: !2, type: !63) +!55 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) +!56 = !{!57} +!57 = !DILocalVariable(name: "ctx", arg: 1, scope: !51, file: !2, type: !54) diff --git a/tests/codegen/llvm/string_equal_comparison.ll b/tests/codegen/llvm/string_equal_comparison.ll index 7c8fabc50..54db9ae02 100644 --- a/tests/codegen/llvm/string_equal_comparison.ll +++ b/tests/codegen/llvm/string_equal_comparison.ll @@ -9,17 +9,16 @@ target triple = "bpf-pc-linux" @LICENSE = global [4 x i8] c"GPL\00", section "license" @AT_ = dso_local global %"struct map_t" zeroinitializer, section ".maps", !dbg !0 -@ringbuf = dso_local global %"struct map_t.0" zeroinitializer, section ".maps", !dbg !25 -@event_loss_counter = dso_local global %"struct map_t.1" zeroinitializer, section ".maps", !dbg !39 +@ringbuf = dso_local global %"struct map_t.0" zeroinitializer, section ".maps", !dbg !20 +@event_loss_counter = dso_local global %"struct map_t.1" zeroinitializer, section ".maps", !dbg !34 ; Function Attrs: nounwind declare i64 @llvm.bpf.pseudo(i64 %0, i64 %1) #0 -define i64 @kretprobe_vfs_read_1(i8* %0) section "s_kretprobe_vfs_read_1" !dbg !60 { +define i64 @kprobe_f_1(i8* %0) section "s_kprobe_f_1" !dbg !51 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 - %comm17 = alloca [16 x i8], align 1 + %"@_val" = alloca i64, align 8 + %"@_key" = alloca i64, align 8 %strcmp.result = alloca i1, align 1 %comm = alloca [16 x i8], align 1 %1 = bitcast [16 x i8]* %comm to i8* @@ -36,40 +35,35 @@ entry: %strcmp.cmp = icmp ne i8 %6, 115 br i1 %strcmp.cmp, label %strcmp.false, label %strcmp.loop_null_cmp -pred_false: ; preds = %strcmp.false - ret i64 0 - -pred_true: ; preds = %strcmp.false - %7 = bitcast [16 x i8]* %comm to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %7) - %8 = bitcast [16 x i8]* %comm17 to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %8) - %9 = bitcast [16 x i8]* %comm17 to i8* - call void @llvm.memset.p0i8.i64(i8* align 1 %9, i8 0, i64 16, i1 false) - %get_comm18 = call i64 inttoptr (i64 16 to i64 ([16 x i8]*, i64)*)([16 x i8]* %comm17, i64 16) - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, [16 x i8]*)*)(%"struct map_t"* @AT_, [16 x i8]* %comm17) - %10 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %10) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - strcmp.false: ; preds = %strcmp.done, %strcmp.loop9, %strcmp.loop5, %strcmp.loop1, %strcmp.loop, %entry - %11 = load i1, i1* %strcmp.result, align 1 - %12 = bitcast i1* %strcmp.result to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %12) - %13 = zext i1 %11 to i64 - %predcond = icmp eq i64 %13, 0 - br i1 %predcond, label %pred_false, label %pred_true + %7 = load i1, i1* %strcmp.result, align 1 + %8 = bitcast i1* %strcmp.result to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %8) + %9 = zext i1 %7 to i64 + %10 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.start.p0i8(i64 -1, i8* %10) + store i64 %9, i64* %"@_key", align 8 + %11 = bitcast [16 x i8]* %comm to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %11) + %12 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.start.p0i8(i64 -1, i8* %12) + store i64 1, i64* %"@_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %"@_val", i64 0) + %13 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %13) + %14 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %14) + ret i64 0 strcmp.done: ; preds = %strcmp.loop13, %strcmp.loop_null_cmp14, %strcmp.loop_null_cmp10, %strcmp.loop_null_cmp6, %strcmp.loop_null_cmp2, %strcmp.loop_null_cmp store i1 true, i1* %strcmp.result, align 1 br label %strcmp.false strcmp.loop: ; preds = %strcmp.loop_null_cmp - %14 = bitcast [16 x i8]* %comm to i8* - %15 = getelementptr i8, i8* %14, i32 1 - %16 = load i8, i8* %15, align 1 - %strcmp.cmp3 = icmp ne i8 %16, 115 + %15 = bitcast [16 x i8]* %comm to i8* + %16 = getelementptr i8, i8* %15, i32 1 + %17 = load i8, i8* %16, align 1 + %strcmp.cmp3 = icmp ne i8 %17, 115 br i1 %strcmp.cmp3, label %strcmp.false, label %strcmp.loop_null_cmp2 strcmp.loop_null_cmp: ; preds = %entry @@ -77,65 +71,44 @@ strcmp.loop_null_cmp: ; preds = %entry br i1 %strcmp.cmp_null, label %strcmp.done, label %strcmp.loop strcmp.loop1: ; preds = %strcmp.loop_null_cmp2 - %17 = bitcast [16 x i8]* %comm to i8* - %18 = getelementptr i8, i8* %17, i32 2 - %19 = load i8, i8* %18, align 1 - %strcmp.cmp7 = icmp ne i8 %19, 104 + %18 = bitcast [16 x i8]* %comm to i8* + %19 = getelementptr i8, i8* %18, i32 2 + %20 = load i8, i8* %19, align 1 + %strcmp.cmp7 = icmp ne i8 %20, 104 br i1 %strcmp.cmp7, label %strcmp.false, label %strcmp.loop_null_cmp6 strcmp.loop_null_cmp2: ; preds = %strcmp.loop - %strcmp.cmp_null4 = icmp eq i8 %16, 0 + %strcmp.cmp_null4 = icmp eq i8 %17, 0 br i1 %strcmp.cmp_null4, label %strcmp.done, label %strcmp.loop1 strcmp.loop5: ; preds = %strcmp.loop_null_cmp6 - %20 = bitcast [16 x i8]* %comm to i8* - %21 = getelementptr i8, i8* %20, i32 3 - %22 = load i8, i8* %21, align 1 - %strcmp.cmp11 = icmp ne i8 %22, 100 + %21 = bitcast [16 x i8]* %comm to i8* + %22 = getelementptr i8, i8* %21, i32 3 + %23 = load i8, i8* %22, align 1 + %strcmp.cmp11 = icmp ne i8 %23, 100 br i1 %strcmp.cmp11, label %strcmp.false, label %strcmp.loop_null_cmp10 strcmp.loop_null_cmp6: ; preds = %strcmp.loop1 - %strcmp.cmp_null8 = icmp eq i8 %19, 0 + %strcmp.cmp_null8 = icmp eq i8 %20, 0 br i1 %strcmp.cmp_null8, label %strcmp.done, label %strcmp.loop5 strcmp.loop9: ; preds = %strcmp.loop_null_cmp10 - %23 = bitcast [16 x i8]* %comm to i8* - %24 = getelementptr i8, i8* %23, i32 4 - %25 = load i8, i8* %24, align 1 - %strcmp.cmp15 = icmp ne i8 %25, 0 + %24 = bitcast [16 x i8]* %comm to i8* + %25 = getelementptr i8, i8* %24, i32 4 + %26 = load i8, i8* %25, align 1 + %strcmp.cmp15 = icmp ne i8 %26, 0 br i1 %strcmp.cmp15, label %strcmp.false, label %strcmp.loop_null_cmp14 strcmp.loop_null_cmp10: ; preds = %strcmp.loop5 - %strcmp.cmp_null12 = icmp eq i8 %22, 0 + %strcmp.cmp_null12 = icmp eq i8 %23, 0 br i1 %strcmp.cmp_null12, label %strcmp.done, label %strcmp.loop9 strcmp.loop13: ; preds = %strcmp.loop_null_cmp14 br label %strcmp.done strcmp.loop_null_cmp14: ; preds = %strcmp.loop9 - %strcmp.cmp_null16 = icmp eq i8 %25, 0 + %strcmp.cmp_null16 = icmp eq i8 %26, 0 br i1 %strcmp.cmp_null16, label %strcmp.done, label %strcmp.loop13 - -lookup_success: ; preds = %pred_true - %cast = bitcast i8* %lookup_elem to i64* - %26 = load i64, i64* %cast, align 8 - %27 = add i64 %26, 1 - store i64 %27, i64* %cast, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %pred_true - %28 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %28) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, [16 x i8]*, i64*, i64)*)(%"struct map_t"* @AT_, [16 x i8]* %comm17, i64* %initial_value, i64 1) - %29 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %29) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %30 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %30) - ret i64 0 } ; Function Attrs: argmemonly nofree nosync nounwind willreturn @@ -151,20 +124,20 @@ attributes #0 = { nounwind } attributes #1 = { argmemonly nofree nosync nounwind willreturn } attributes #2 = { argmemonly nofree nosync nounwind willreturn writeonly } -!llvm.dbg.cu = !{!56} -!llvm.module.flags = !{!59} +!llvm.dbg.cu = !{!47} +!llvm.module.flags = !{!50} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "AT_", linkageName: "global", scope: !2, file: !2, type: !3, isLocal: false, isDefinition: true) !2 = !DIFile(filename: "bpftrace.bpf.o", directory: ".") !3 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !4) -!4 = !{!5, !11, !16, !22} +!4 = !{!5, !11, !16, !19} !5 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !6, size: 64) !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 160, elements: !9) +!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !9) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !9 = !{!10} -!10 = !DISubrange(count: 5, lowerBound: 0) +!10 = !DISubrange(count: 1, lowerBound: 0) !11 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !12, size: 64, offset: 64) !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) !13 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 131072, elements: !14) @@ -172,51 +145,43 @@ attributes #2 = { argmemonly nofree nosync nounwind willreturn writeonly } !15 = !DISubrange(count: 4096, lowerBound: 0) !16 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !17, size: 64, offset: 128) !17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !18, size: 64) -!18 = !DICompositeType(tag: DW_TAG_array_type, baseType: !19, size: 128, elements: !20) -!19 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) -!20 = !{!21} -!21 = !DISubrange(count: 16, lowerBound: 0) -!22 = !DIDerivedType(tag: DW_TAG_member, name: "value", scope: !2, file: !2, baseType: !23, size: 64, offset: 192) -!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !24, size: 64) -!24 = !DIBasicType(name: "int64", size: 64, encoding: DW_ATE_signed) -!25 = !DIGlobalVariableExpression(var: !26, expr: !DIExpression()) -!26 = distinct !DIGlobalVariable(name: "ringbuf", linkageName: "global", scope: !2, file: !2, type: !27, isLocal: false, isDefinition: true) -!27 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 128, elements: !28) -!28 = !{!29, !34} -!29 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !30, size: 64) +!18 = !DIBasicType(name: "int64", size: 64, encoding: DW_ATE_signed) +!19 = !DIDerivedType(tag: DW_TAG_member, name: "value", scope: !2, file: !2, baseType: !17, size: 64, offset: 192) +!20 = !DIGlobalVariableExpression(var: !21, expr: !DIExpression()) +!21 = distinct !DIGlobalVariable(name: "ringbuf", linkageName: "global", scope: !2, file: !2, type: !22, isLocal: false, isDefinition: true) +!22 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 128, elements: !23) +!23 = !{!24, !29} +!24 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !25, size: 64) +!25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !26, size: 64) +!26 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 864, elements: !27) +!27 = !{!28} +!28 = !DISubrange(count: 27, lowerBound: 0) +!29 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !30, size: 64, offset: 64) !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !31, size: 64) -!31 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 864, elements: !32) +!31 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 8388608, elements: !32) !32 = !{!33} -!33 = !DISubrange(count: 27, lowerBound: 0) -!34 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !35, size: 64, offset: 64) -!35 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !36, size: 64) -!36 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 8388608, elements: !37) -!37 = !{!38} -!38 = !DISubrange(count: 262144, lowerBound: 0) -!39 = !DIGlobalVariableExpression(var: !40, expr: !DIExpression()) -!40 = distinct !DIGlobalVariable(name: "event_loss_counter", linkageName: "global", scope: !2, file: !2, type: !41, isLocal: false, isDefinition: true) -!41 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !42) -!42 = !{!43, !48, !53, !22} -!43 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !44, size: 64) -!44 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !45, size: 64) -!45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 64, elements: !46) -!46 = !{!47} -!47 = !DISubrange(count: 2, lowerBound: 0) -!48 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !49, size: 64, offset: 64) -!49 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !50, size: 64) -!50 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !51) -!51 = !{!52} -!52 = !DISubrange(count: 1, lowerBound: 0) -!53 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !54, size: 64, offset: 128) +!33 = !DISubrange(count: 262144, lowerBound: 0) +!34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) +!35 = distinct !DIGlobalVariable(name: "event_loss_counter", linkageName: "global", scope: !2, file: !2, type: !36, isLocal: false, isDefinition: true) +!36 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !37) +!37 = !{!38, !43, !44, !19} +!38 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !39, size: 64) +!39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !40, size: 64) +!40 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 64, elements: !41) +!41 = !{!42} +!42 = !DISubrange(count: 2, lowerBound: 0) +!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !6, size: 64, offset: 64) +!44 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !45, size: 64, offset: 128) +!45 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !46, size: 64) +!46 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) +!47 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !48, globals: !49) +!48 = !{} +!49 = !{!0, !20, !34} +!50 = !{i32 2, !"Debug Info Version", i32 3} +!51 = distinct !DISubprogram(name: "kprobe_f_1", linkageName: "kprobe_f_1", scope: !2, file: !2, type: !52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !56) +!52 = !DISubroutineType(types: !53) +!53 = !{!18, !54} !54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !55, size: 64) -!55 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) -!56 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !57, globals: !58) -!57 = !{} -!58 = !{!0, !25, !39} -!59 = !{i32 2, !"Debug Info Version", i32 3} -!60 = distinct !DISubprogram(name: "kretprobe_vfs_read_1", linkageName: "kretprobe_vfs_read_1", scope: !2, file: !2, type: !61, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !56, retainedNodes: !64) -!61 = !DISubroutineType(types: !62) -!62 = !{!24, !63} -!63 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64) -!64 = !{!65} -!65 = !DILocalVariable(name: "ctx", arg: 1, scope: !60, file: !2, type: !63) +!55 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) +!56 = !{!57} +!57 = !DILocalVariable(name: "ctx", arg: 1, scope: !51, file: !2, type: !54) diff --git a/tests/codegen/llvm/string_not_equal_comparison.ll b/tests/codegen/llvm/string_not_equal_comparison.ll index 513e536ef..06df418b6 100644 --- a/tests/codegen/llvm/string_not_equal_comparison.ll +++ b/tests/codegen/llvm/string_not_equal_comparison.ll @@ -9,17 +9,16 @@ target triple = "bpf-pc-linux" @LICENSE = global [4 x i8] c"GPL\00", section "license" @AT_ = dso_local global %"struct map_t" zeroinitializer, section ".maps", !dbg !0 -@ringbuf = dso_local global %"struct map_t.0" zeroinitializer, section ".maps", !dbg !25 -@event_loss_counter = dso_local global %"struct map_t.1" zeroinitializer, section ".maps", !dbg !39 +@ringbuf = dso_local global %"struct map_t.0" zeroinitializer, section ".maps", !dbg !20 +@event_loss_counter = dso_local global %"struct map_t.1" zeroinitializer, section ".maps", !dbg !34 ; Function Attrs: nounwind declare i64 @llvm.bpf.pseudo(i64 %0, i64 %1) #0 -define i64 @kretprobe_vfs_read_1(i8* %0) section "s_kretprobe_vfs_read_1" !dbg !60 { +define i64 @kprobe_f_1(i8* %0) section "s_kprobe_f_1" !dbg !51 { entry: - %initial_value = alloca i64, align 8 - %lookup_elem_val = alloca i64, align 8 - %comm17 = alloca [16 x i8], align 1 + %"@_val" = alloca i64, align 8 + %"@_key" = alloca i64, align 8 %strcmp.result = alloca i1, align 1 %comm = alloca [16 x i8], align 1 %1 = bitcast [16 x i8]* %comm to i8* @@ -36,40 +35,35 @@ entry: %strcmp.cmp = icmp ne i8 %6, 115 br i1 %strcmp.cmp, label %strcmp.false, label %strcmp.loop_null_cmp -pred_false: ; preds = %strcmp.false - ret i64 0 - -pred_true: ; preds = %strcmp.false - %7 = bitcast [16 x i8]* %comm to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %7) - %8 = bitcast [16 x i8]* %comm17 to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %8) - %9 = bitcast [16 x i8]* %comm17 to i8* - call void @llvm.memset.p0i8.i64(i8* align 1 %9, i8 0, i64 16, i1 false) - %get_comm18 = call i64 inttoptr (i64 16 to i64 ([16 x i8]*, i64)*)([16 x i8]* %comm17, i64 16) - %lookup_elem = call i8* inttoptr (i64 1 to i8* (%"struct map_t"*, [16 x i8]*)*)(%"struct map_t"* @AT_, [16 x i8]* %comm17) - %10 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %10) - %map_lookup_cond = icmp ne i8* %lookup_elem, null - br i1 %map_lookup_cond, label %lookup_success, label %lookup_failure - strcmp.false: ; preds = %strcmp.done, %strcmp.loop9, %strcmp.loop5, %strcmp.loop1, %strcmp.loop, %entry - %11 = load i1, i1* %strcmp.result, align 1 - %12 = bitcast i1* %strcmp.result to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %12) - %13 = zext i1 %11 to i64 - %predcond = icmp eq i64 %13, 0 - br i1 %predcond, label %pred_false, label %pred_true + %7 = load i1, i1* %strcmp.result, align 1 + %8 = bitcast i1* %strcmp.result to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %8) + %9 = zext i1 %7 to i64 + %10 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.start.p0i8(i64 -1, i8* %10) + store i64 %9, i64* %"@_key", align 8 + %11 = bitcast [16 x i8]* %comm to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %11) + %12 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.start.p0i8(i64 -1, i8* %12) + store i64 1, i64* %"@_val", align 8 + %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, i64*, i64*, i64)*)(%"struct map_t"* @AT_, i64* %"@_key", i64* %"@_val", i64 0) + %13 = bitcast i64* %"@_val" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %13) + %14 = bitcast i64* %"@_key" to i8* + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %14) + ret i64 0 strcmp.done: ; preds = %strcmp.loop13, %strcmp.loop_null_cmp14, %strcmp.loop_null_cmp10, %strcmp.loop_null_cmp6, %strcmp.loop_null_cmp2, %strcmp.loop_null_cmp store i1 false, i1* %strcmp.result, align 1 br label %strcmp.false strcmp.loop: ; preds = %strcmp.loop_null_cmp - %14 = bitcast [16 x i8]* %comm to i8* - %15 = getelementptr i8, i8* %14, i32 1 - %16 = load i8, i8* %15, align 1 - %strcmp.cmp3 = icmp ne i8 %16, 115 + %15 = bitcast [16 x i8]* %comm to i8* + %16 = getelementptr i8, i8* %15, i32 1 + %17 = load i8, i8* %16, align 1 + %strcmp.cmp3 = icmp ne i8 %17, 115 br i1 %strcmp.cmp3, label %strcmp.false, label %strcmp.loop_null_cmp2 strcmp.loop_null_cmp: ; preds = %entry @@ -77,65 +71,44 @@ strcmp.loop_null_cmp: ; preds = %entry br i1 %strcmp.cmp_null, label %strcmp.done, label %strcmp.loop strcmp.loop1: ; preds = %strcmp.loop_null_cmp2 - %17 = bitcast [16 x i8]* %comm to i8* - %18 = getelementptr i8, i8* %17, i32 2 - %19 = load i8, i8* %18, align 1 - %strcmp.cmp7 = icmp ne i8 %19, 104 + %18 = bitcast [16 x i8]* %comm to i8* + %19 = getelementptr i8, i8* %18, i32 2 + %20 = load i8, i8* %19, align 1 + %strcmp.cmp7 = icmp ne i8 %20, 104 br i1 %strcmp.cmp7, label %strcmp.false, label %strcmp.loop_null_cmp6 strcmp.loop_null_cmp2: ; preds = %strcmp.loop - %strcmp.cmp_null4 = icmp eq i8 %16, 0 + %strcmp.cmp_null4 = icmp eq i8 %17, 0 br i1 %strcmp.cmp_null4, label %strcmp.done, label %strcmp.loop1 strcmp.loop5: ; preds = %strcmp.loop_null_cmp6 - %20 = bitcast [16 x i8]* %comm to i8* - %21 = getelementptr i8, i8* %20, i32 3 - %22 = load i8, i8* %21, align 1 - %strcmp.cmp11 = icmp ne i8 %22, 100 + %21 = bitcast [16 x i8]* %comm to i8* + %22 = getelementptr i8, i8* %21, i32 3 + %23 = load i8, i8* %22, align 1 + %strcmp.cmp11 = icmp ne i8 %23, 100 br i1 %strcmp.cmp11, label %strcmp.false, label %strcmp.loop_null_cmp10 strcmp.loop_null_cmp6: ; preds = %strcmp.loop1 - %strcmp.cmp_null8 = icmp eq i8 %19, 0 + %strcmp.cmp_null8 = icmp eq i8 %20, 0 br i1 %strcmp.cmp_null8, label %strcmp.done, label %strcmp.loop5 strcmp.loop9: ; preds = %strcmp.loop_null_cmp10 - %23 = bitcast [16 x i8]* %comm to i8* - %24 = getelementptr i8, i8* %23, i32 4 - %25 = load i8, i8* %24, align 1 - %strcmp.cmp15 = icmp ne i8 %25, 0 + %24 = bitcast [16 x i8]* %comm to i8* + %25 = getelementptr i8, i8* %24, i32 4 + %26 = load i8, i8* %25, align 1 + %strcmp.cmp15 = icmp ne i8 %26, 0 br i1 %strcmp.cmp15, label %strcmp.false, label %strcmp.loop_null_cmp14 strcmp.loop_null_cmp10: ; preds = %strcmp.loop5 - %strcmp.cmp_null12 = icmp eq i8 %22, 0 + %strcmp.cmp_null12 = icmp eq i8 %23, 0 br i1 %strcmp.cmp_null12, label %strcmp.done, label %strcmp.loop9 strcmp.loop13: ; preds = %strcmp.loop_null_cmp14 br label %strcmp.done strcmp.loop_null_cmp14: ; preds = %strcmp.loop9 - %strcmp.cmp_null16 = icmp eq i8 %25, 0 + %strcmp.cmp_null16 = icmp eq i8 %26, 0 br i1 %strcmp.cmp_null16, label %strcmp.done, label %strcmp.loop13 - -lookup_success: ; preds = %pred_true - %cast = bitcast i8* %lookup_elem to i64* - %26 = load i64, i64* %cast, align 8 - %27 = add i64 %26, 1 - store i64 %27, i64* %cast, align 8 - br label %lookup_merge - -lookup_failure: ; preds = %pred_true - %28 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.start.p0i8(i64 -1, i8* %28) - store i64 1, i64* %initial_value, align 8 - %update_elem = call i64 inttoptr (i64 2 to i64 (%"struct map_t"*, [16 x i8]*, i64*, i64)*)(%"struct map_t"* @AT_, [16 x i8]* %comm17, i64* %initial_value, i64 1) - %29 = bitcast i64* %initial_value to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %29) - br label %lookup_merge - -lookup_merge: ; preds = %lookup_failure, %lookup_success - %30 = bitcast i64* %lookup_elem_val to i8* - call void @llvm.lifetime.end.p0i8(i64 -1, i8* %30) - ret i64 0 } ; Function Attrs: argmemonly nofree nosync nounwind willreturn @@ -151,20 +124,20 @@ attributes #0 = { nounwind } attributes #1 = { argmemonly nofree nosync nounwind willreturn } attributes #2 = { argmemonly nofree nosync nounwind willreturn writeonly } -!llvm.dbg.cu = !{!56} -!llvm.module.flags = !{!59} +!llvm.dbg.cu = !{!47} +!llvm.module.flags = !{!50} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !1 = distinct !DIGlobalVariable(name: "AT_", linkageName: "global", scope: !2, file: !2, type: !3, isLocal: false, isDefinition: true) !2 = !DIFile(filename: "bpftrace.bpf.o", directory: ".") !3 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !4) -!4 = !{!5, !11, !16, !22} +!4 = !{!5, !11, !16, !19} !5 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !6, size: 64) !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 160, elements: !9) +!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !9) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !9 = !{!10} -!10 = !DISubrange(count: 5, lowerBound: 0) +!10 = !DISubrange(count: 1, lowerBound: 0) !11 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !12, size: 64, offset: 64) !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) !13 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 131072, elements: !14) @@ -172,51 +145,43 @@ attributes #2 = { argmemonly nofree nosync nounwind willreturn writeonly } !15 = !DISubrange(count: 4096, lowerBound: 0) !16 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !17, size: 64, offset: 128) !17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !18, size: 64) -!18 = !DICompositeType(tag: DW_TAG_array_type, baseType: !19, size: 128, elements: !20) -!19 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) -!20 = !{!21} -!21 = !DISubrange(count: 16, lowerBound: 0) -!22 = !DIDerivedType(tag: DW_TAG_member, name: "value", scope: !2, file: !2, baseType: !23, size: 64, offset: 192) -!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !24, size: 64) -!24 = !DIBasicType(name: "int64", size: 64, encoding: DW_ATE_signed) -!25 = !DIGlobalVariableExpression(var: !26, expr: !DIExpression()) -!26 = distinct !DIGlobalVariable(name: "ringbuf", linkageName: "global", scope: !2, file: !2, type: !27, isLocal: false, isDefinition: true) -!27 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 128, elements: !28) -!28 = !{!29, !34} -!29 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !30, size: 64) +!18 = !DIBasicType(name: "int64", size: 64, encoding: DW_ATE_signed) +!19 = !DIDerivedType(tag: DW_TAG_member, name: "value", scope: !2, file: !2, baseType: !17, size: 64, offset: 192) +!20 = !DIGlobalVariableExpression(var: !21, expr: !DIExpression()) +!21 = distinct !DIGlobalVariable(name: "ringbuf", linkageName: "global", scope: !2, file: !2, type: !22, isLocal: false, isDefinition: true) +!22 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 128, elements: !23) +!23 = !{!24, !29} +!24 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !25, size: 64) +!25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !26, size: 64) +!26 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 864, elements: !27) +!27 = !{!28} +!28 = !DISubrange(count: 27, lowerBound: 0) +!29 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !30, size: 64, offset: 64) !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !31, size: 64) -!31 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 864, elements: !32) +!31 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 8388608, elements: !32) !32 = !{!33} -!33 = !DISubrange(count: 27, lowerBound: 0) -!34 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !35, size: 64, offset: 64) -!35 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !36, size: 64) -!36 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 8388608, elements: !37) -!37 = !{!38} -!38 = !DISubrange(count: 262144, lowerBound: 0) -!39 = !DIGlobalVariableExpression(var: !40, expr: !DIExpression()) -!40 = distinct !DIGlobalVariable(name: "event_loss_counter", linkageName: "global", scope: !2, file: !2, type: !41, isLocal: false, isDefinition: true) -!41 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !42) -!42 = !{!43, !48, !53, !22} -!43 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !44, size: 64) -!44 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !45, size: 64) -!45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 64, elements: !46) -!46 = !{!47} -!47 = !DISubrange(count: 2, lowerBound: 0) -!48 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !49, size: 64, offset: 64) -!49 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !50, size: 64) -!50 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 32, elements: !51) -!51 = !{!52} -!52 = !DISubrange(count: 1, lowerBound: 0) -!53 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !54, size: 64, offset: 128) +!33 = !DISubrange(count: 262144, lowerBound: 0) +!34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) +!35 = distinct !DIGlobalVariable(name: "event_loss_counter", linkageName: "global", scope: !2, file: !2, type: !36, isLocal: false, isDefinition: true) +!36 = !DICompositeType(tag: DW_TAG_structure_type, scope: !2, file: !2, size: 256, elements: !37) +!37 = !{!38, !43, !44, !19} +!38 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !2, file: !2, baseType: !39, size: 64) +!39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !40, size: 64) +!40 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 64, elements: !41) +!41 = !{!42} +!42 = !DISubrange(count: 2, lowerBound: 0) +!43 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !2, file: !2, baseType: !6, size: 64, offset: 64) +!44 = !DIDerivedType(tag: DW_TAG_member, name: "key", scope: !2, file: !2, baseType: !45, size: 64, offset: 128) +!45 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !46, size: 64) +!46 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) +!47 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !48, globals: !49) +!48 = !{} +!49 = !{!0, !20, !34} +!50 = !{i32 2, !"Debug Info Version", i32 3} +!51 = distinct !DISubprogram(name: "kprobe_f_1", linkageName: "kprobe_f_1", scope: !2, file: !2, type: !52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !56) +!52 = !DISubroutineType(types: !53) +!53 = !{!18, !54} !54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !55, size: 64) -!55 = !DIBasicType(name: "int32", size: 32, encoding: DW_ATE_signed) -!56 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "bpftrace", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !57, globals: !58) -!57 = !{} -!58 = !{!0, !25, !39} -!59 = !{i32 2, !"Debug Info Version", i32 3} -!60 = distinct !DISubprogram(name: "kretprobe_vfs_read_1", linkageName: "kretprobe_vfs_read_1", scope: !2, file: !2, type: !61, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !56, retainedNodes: !64) -!61 = !DISubroutineType(types: !62) -!62 = !{!24, !63} -!63 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64) -!64 = !{!65} -!65 = !DILocalVariable(name: "ctx", arg: 1, scope: !60, file: !2, type: !63) +!55 = !DIBasicType(name: "int8", size: 8, encoding: DW_ATE_signed) +!56 = !{!57} +!57 = !DILocalVariable(name: "ctx", arg: 1, scope: !51, file: !2, type: !54) diff --git a/tests/codegen/string_equal_comparison.cpp b/tests/codegen/string_equal_comparison.cpp index e866939f8..e0d0675a7 100644 --- a/tests/codegen/string_equal_comparison.cpp +++ b/tests/codegen/string_equal_comparison.cpp @@ -6,7 +6,7 @@ namespace codegen { TEST(codegen, string_equal_comparison) { - test("kretprobe:vfs_read /comm == \"sshd\"/ { @[comm] = count(); }", + test("kprobe:f { @[comm == \"sshd\"] = 1; }", NAME); } diff --git a/tests/codegen/string_not_equal_comparison.cpp b/tests/codegen/string_not_equal_comparison.cpp index 16a6352fb..1598490dd 100644 --- a/tests/codegen/string_not_equal_comparison.cpp +++ b/tests/codegen/string_not_equal_comparison.cpp @@ -6,7 +6,7 @@ namespace codegen { TEST(codegen, string_not_equal_comparison) { - test("kretprobe:vfs_read /comm != \"sshd\"/ { @[comm] = count(); }", + test("kprobe:f { @[comm != \"sshd\"] = 1; }", NAME); }