bpftrace numaid部分patch

这篇博客讨论了BPF(Berkeley Packet Filter)代码中的一个变更,涉及将`bpf_get_numa_node_id`函数返回类型从Long改为Int。变更包括在`irbuilderbpf.cpp`和`codegen_llvm.cpp`文件中,同时处理了类型转换以确保正确性。这可能影响到依赖于该函数返回值的内存分配和NUMA节点管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Or this patch is OK?

diff --git a/src/ast/irbuilderbpf.cpp b/src/ast/irbuilderbpf.cpp
index c0adc335..72e2d7e1 100644
--- a/src/ast/irbuilderbpf.cpp
+++ b/src/ast/irbuilderbpf.cpp
@@ -910,7 +910,7 @@ CallInst *IRBuilderBPF::CreateGetNumaId()
 {
   // long bpf_get_numa_node_id(void)
   // Return: NUMA Node ID
-  FunctionType *getnumaid_func_type = FunctionType::get(getInt64Ty(), false);
+  FunctionType *getnumaid_func_type = FunctionType::get(getInt32Ty(), false);
   PointerType *getnumaid_func_ptr_type = PointerType::get(getnumaid_func_type, 0);
   Constant *getnumaid_func = ConstantExpr::getCast(
       Instruction::IntToPtr,
diff --git a/src/ast/passes/codegen_llvm.cpp b/src/ast/passes/codegen_llvm.cpp
index b7980f15..763a19b8 100644
--- a/src/ast/passes/codegen_llvm.cpp
+++ b/src/ast/passes/codegen_llvm.cpp
@@ -171,7 +171,8 @@ void CodegenLLVM::visit(Builtin &builtin)
   }
   else if (builtin.ident == "numaid")
   {
-    expr_ = b_.CreateGetNumaId();
+    Value *tmp = b_.CreateGetNumaId();
+    expr_ = b_.CreateZExt(tmp, b_.getInt64Ty());
   }
   else if (builtin.ident == "cpu")
   {
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值