summaryrefslogtreecommitdiffstats
path: root/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch
diff options
context:
space:
mode:
Diffstat (limited to 'dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch')
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch338
1 files changed, 338 insertions, 0 deletions
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch
new file mode 100644
index 0000000..9167963
--- /dev/null
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch
@@ -0,0 +1,338 @@
1From 441f38a0fa9711a08ca8d904b542559593bffb16 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 16 Feb 2024 10:32:27 -0800
4Subject: [PATCH 2/4] ast: Repace getInt8PtrTy with getPtrTy
5
6getPtrTy is added in LLVM-15 and is to be used instead of getInt8PtrTy
7which is gone in LLVM-18 onwards
8
9https://github.com/llvm/llvm-project/commit/7e0802aeb5b90
10
11Upstream-Status: Submitted [https://github.com/bpftrace/bpftrace/pull/3009]
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14 src/ast/irbuilderbpf.cpp | 58 ++++++++++++++++-----------------
15 src/ast/passes/codegen_llvm.cpp | 22 ++++++-------
16 2 files changed, 40 insertions(+), 40 deletions(-)
17
18diff --git a/src/ast/irbuilderbpf.cpp b/src/ast/irbuilderbpf.cpp
19index 670a9e98..2ff3c0ce 100644
20--- a/src/ast/irbuilderbpf.cpp
21+++ b/src/ast/irbuilderbpf.cpp
22@@ -301,7 +301,7 @@ CallInst *IRBuilderBPF::createMapLookup(const std::string &map_name,
23 Value *key,
24 const std::string &name)
25 {
26- return createMapLookup(map_name, key, getInt8PtrTy(), name);
27+ return createMapLookup(map_name, key, getPtrTy(), name);
28 }
29
30 CallInst *IRBuilderBPF::createMapLookup(const std::string &map_name,
31@@ -329,7 +329,7 @@ CallInst *IRBuilderBPF::CreateGetJoinMap(BasicBlock *failure_callback,
32 {
33 return createGetScratchMap(to_string(MapManager::Type::Join),
34 "join",
35- getInt8PtrTy(),
36+ getPtrTy(),
37 loc,
38 failure_callback);
39 }
40@@ -358,8 +358,8 @@ CallInst *IRBuilderBPF::createGetScratchMap(const std::string &map_name,
41 BasicBlock *lookup_merge_block = BasicBlock::Create(
42 module_.getContext(), "lookup_" + name + "_merge", parent);
43 Value *condition = CreateICmpNE(
44- CreateIntCast(call, getInt8PtrTy(), true),
45- ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getInt8PtrTy()),
46+ CreateIntCast(call, getPtrTy(), true),
47+ ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getPtrTy()),
48 "lookup_" + name + "_cond");
49 CreateCondBr(condition, lookup_merge_block, lookup_failure_block);
50
51@@ -379,7 +379,7 @@ Value *IRBuilderBPF::CreateMapLookupElem(Value *ctx,
52 Value *key,
53 const location &loc)
54 {
55- assert(ctx && ctx->getType() == getInt8PtrTy());
56+ assert(ctx && ctx->getType() == getPtrTy());
57 return CreateMapLookupElem(ctx, map.ident, key, map.type, loc);
58 }
59
60@@ -389,7 +389,7 @@ Value *IRBuilderBPF::CreateMapLookupElem(Value *ctx,
61 SizedType &type,
62 const location &loc)
63 {
64- assert(ctx && ctx->getType() == getInt8PtrTy());
65+ assert(ctx && ctx->getType() == getPtrTy());
66 CallInst *call = createMapLookup(map_name, key);
67
68 // Check if result == 0
69@@ -406,8 +406,8 @@ Value *IRBuilderBPF::CreateMapLookupElem(Value *ctx,
70
71 AllocaInst *value = CreateAllocaBPF(type, "lookup_elem_val");
72 Value *condition = CreateICmpNE(
73- CreateIntCast(call, getInt8PtrTy(), true),
74- ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getInt8PtrTy()),
75+ CreateIntCast(call, getPtrTy(), true),
76+ ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getPtrTy()),
77 "map_lookup_cond");
78 CreateCondBr(condition, lookup_success_block, lookup_failure_block);
79
80@@ -449,7 +449,7 @@ void IRBuilderBPF::CreateMapUpdateElem(Value *ctx,
81 {
82 Value *map_ptr = GetMapVar(map.ident);
83
84- assert(ctx && ctx->getType() == getInt8PtrTy());
85+ assert(ctx && ctx->getType() == getPtrTy());
86 assert(key->getType()->isPointerTy());
87 assert(val->getType()->isPointerTy());
88
89@@ -478,7 +478,7 @@ void IRBuilderBPF::CreateMapDeleteElem(Value *ctx,
90 Value *key,
91 const location &loc)
92 {
93- assert(ctx && ctx->getType() == getInt8PtrTy());
94+ assert(ctx && ctx->getType() == getPtrTy());
95 assert(key->getType()->isPointerTy());
96 Value *map_ptr = GetMapVar(map.ident);
97
98@@ -541,7 +541,7 @@ void IRBuilderBPF::CreateProbeRead(Value *ctx,
99 AddrSpace as,
100 const location &loc)
101 {
102- assert(ctx && ctx->getType() == getInt8PtrTy());
103+ assert(ctx && ctx->getType() == getPtrTy());
104 assert(size && size->getType()->getIntegerBitWidth() <= 32);
105 size = CreateIntCast(size, getInt32Ty(), false);
106
107@@ -581,7 +581,7 @@ CallInst *IRBuilderBPF::CreateProbeReadStr(Value *ctx,
108 AddrSpace as,
109 const location &loc)
110 {
111- assert(ctx && ctx->getType() == getInt8PtrTy());
112+ assert(ctx && ctx->getType() == getPtrTy());
113 assert(size && size->getType()->isIntegerTy());
114 if ([[maybe_unused]] auto *dst_alloca = dyn_cast<AllocaInst>(dst)) {
115 assert(dst_alloca->getAllocatedType()->isArrayTy() &&
116@@ -615,7 +615,7 @@ Value *IRBuilderBPF::CreateUSDTReadArgument(Value *ctx,
117 AddrSpace as,
118 const location &loc)
119 {
120- assert(ctx && ctx->getType() == getInt8PtrTy());
121+ assert(ctx && ctx->getType() == getPtrTy());
122 // Argument size must be 1, 2, 4, or 8. See
123 // https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation
124 int abs_size = std::abs(argument->size);
125@@ -711,7 +711,7 @@ Value *IRBuilderBPF::CreateUSDTReadArgument(Value *ctx,
126 AddrSpace as,
127 const location &loc)
128 {
129- assert(ctx && ctx->getType() == getInt8PtrTy());
130+ assert(ctx && ctx->getType() == getPtrTy());
131 struct bcc_usdt_argument argument;
132
133 void *usdt;
134@@ -1337,7 +1337,7 @@ CallInst *IRBuilderBPF::CreateGetStackId(Value *ctx,
135 StackType stack_type,
136 const location &loc)
137 {
138- assert(ctx && ctx->getType() == getInt8PtrTy());
139+ assert(ctx && ctx->getType() == getPtrTy());
140
141 Value *map_ptr = GetMapVar(stack_type.name());
142
143@@ -1350,7 +1350,7 @@ CallInst *IRBuilderBPF::CreateGetStackId(Value *ctx,
144 // Return: >= 0 stackid on success or negative error
145 FunctionType *getstackid_func_type = FunctionType::get(
146 getInt64Ty(),
147- { getInt8PtrTy(), map_ptr->getType(), getInt64Ty() },
148+ { getPtrTy(), map_ptr->getType(), getInt64Ty() },
149 false);
150 CallInst *call = CreateHelperCall(libbpf::BPF_FUNC_get_stackid,
151 getstackid_func_type,
152@@ -1399,7 +1399,7 @@ void IRBuilderBPF::CreateOutput(Value *ctx,
153 size_t size,
154 const location *loc)
155 {
156- assert(ctx && ctx->getType() == getInt8PtrTy());
157+ assert(ctx && ctx->getType() == getPtrTy());
158 assert(data && data->getType()->isPointerTy());
159
160 if (bpftrace_.feature_->has_map_ringbuf()) {
161@@ -1464,8 +1464,8 @@ void IRBuilderBPF::CreateAtomicIncCounter(const std::string &map_name,
162 parent);
163
164 Value *condition = CreateICmpNE(
165- CreateIntCast(call, getInt8PtrTy(), true),
166- ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getInt8PtrTy()),
167+ CreateIntCast(call, getPtrTy(), true),
168+ ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getPtrTy()),
169 "map_lookup_cond");
170 CreateCondBr(condition, lookup_success_block, lookup_failure_block);
171
172@@ -1521,8 +1521,8 @@ void IRBuilderBPF::CreateMapElemAdd(Value *ctx,
173
174 AllocaInst *value = CreateAllocaBPF(type, "lookup_elem_val");
175 Value *condition = CreateICmpNE(
176- CreateIntCast(call, getInt8PtrTy(), true),
177- ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getInt8PtrTy()),
178+ CreateIntCast(call, getPtrTy(), true),
179+ ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getPtrTy()),
180 "map_lookup_cond");
181 CreateCondBr(condition, lookup_success_block, lookup_failure_block);
182
183@@ -1557,7 +1557,7 @@ void IRBuilderBPF::CreatePerfEventOutput(Value *ctx,
184 // long bpf_perf_event_output(struct pt_regs *ctx, struct bpf_map *map,
185 // u64 flags, void *data, u64 size)
186 FunctionType *perfoutput_func_type = FunctionType::get(getInt64Ty(),
187- { getInt8PtrTy(),
188+ { getPtrTy(),
189 map_ptr->getType(),
190 getInt64Ty(),
191 data->getType(),
192@@ -1600,7 +1600,7 @@ void IRBuilderBPF::CreateTracePrintk(Value *fmt_ptr,
193
194 // long bpf_trace_printk(const char *fmt, u32 fmt_size, ...)
195 FunctionType *traceprintk_func_type = FunctionType::get(
196- getInt64Ty(), { getInt8PtrTy(), getInt32Ty() }, true);
197+ getInt64Ty(), { getPtrTy(), getInt32Ty() }, true);
198
199 CreateHelperCall(libbpf::BPF_FUNC_trace_printk,
200 traceprintk_func_type,
201@@ -1630,7 +1630,7 @@ void IRBuilderBPF::CreateOverrideReturn(Value *ctx, Value *rc)
202 // long bpf_override_return(struct pt_regs *regs, u64 rc)
203 // Return: 0
204 FunctionType *override_func_type = FunctionType::get(
205- getInt64Ty(), { getInt8PtrTy(), getInt64Ty() }, false);
206+ getInt64Ty(), { getPtrTy(), getInt64Ty() }, false);
207 PointerType *override_func_ptr_type = PointerType::get(override_func_type, 0);
208 Constant *override_func = ConstantExpr::getCast(
209 Instruction::IntToPtr,
210@@ -1807,7 +1807,7 @@ void IRBuilderBPF::CreateHelperError(Value *ctx,
211 libbpf::bpf_func_id func_id,
212 const location &loc)
213 {
214- assert(ctx && ctx->getType() == getInt8PtrTy());
215+ assert(ctx && ctx->getType() == getPtrTy());
216 assert(return_value && return_value->getType() == getInt32Ty());
217
218 if (bpftrace_.helper_check_level_ == 0 ||
219@@ -1847,7 +1847,7 @@ void IRBuilderBPF::CreateHelperErrorCond(Value *ctx,
220 const location &loc,
221 bool compare_zero)
222 {
223- assert(ctx && ctx->getType() == getInt8PtrTy());
224+ assert(ctx && ctx->getType() == getPtrTy());
225 if (bpftrace_.helper_check_level_ == 0 ||
226 (bpftrace_.helper_check_level_ == 1 && return_zero_if_err(func_id)))
227 return;
228@@ -1883,7 +1883,7 @@ void IRBuilderBPF::CreatePath(Value *ctx,
229 // int bpf_d_path(struct path *path, char *buf, u32 sz)
230 // Return: 0 or error
231 FunctionType *d_path_func_type = FunctionType::get(
232- getInt64Ty(), { getInt8PtrTy(), buf->getType(), getInt32Ty() }, false);
233+ getInt64Ty(), { getPtrTy(), buf->getType(), getInt32Ty() }, false);
234 CallInst *call = CreateHelperCall(
235 libbpf::bpf_func_id::BPF_FUNC_d_path,
236 d_path_func_type,
237@@ -1905,9 +1905,9 @@ void IRBuilderBPF::CreateSeqPrintf(Value *ctx,
238 // Return: 0 or error
239 FunctionType *seq_printf_func_type = FunctionType::get(getInt64Ty(),
240 { getInt64Ty(),
241- getInt8PtrTy(),
242+ getPtrTy(),
243 getInt32Ty(),
244- getInt8PtrTy(),
245+ getPtrTy(),
246 getInt32Ty() },
247 false);
248 PointerType *seq_printf_func_ptr_type = PointerType::get(seq_printf_func_type,
249diff --git a/src/ast/passes/codegen_llvm.cpp b/src/ast/passes/codegen_llvm.cpp
250index 073d48ae..258b0b0b 100644
251--- a/src/ast/passes/codegen_llvm.cpp
252+++ b/src/ast/passes/codegen_llvm.cpp
253@@ -380,10 +380,10 @@ void CodegenLLVM::visit(Call &call)
254
255 AllocaInst *value = b_.CreateAllocaBPF(type, "lookup_elem_val");
256 Value *condition = b_.CreateICmpNE(
257- b_.CreateIntCast(lookup, b_.getInt8PtrTy(), true),
258+ b_.CreateIntCast(lookup, b_.getPtrTy(), true),
259 ConstantExpr::getCast(Instruction::IntToPtr,
260 b_.getInt64(0),
261- b_.getInt8PtrTy()),
262+ b_.getPtrTy()),
263 "map_lookup_cond");
264 b_.CreateCondBr(condition, lookup_success_block, lookup_failure_block);
265
266@@ -437,10 +437,10 @@ void CodegenLLVM::visit(Call &call)
267
268 AllocaInst *value = b_.CreateAllocaBPF(type, "lookup_elem_val");
269 Value *condition = b_.CreateICmpNE(
270- b_.CreateIntCast(lookup, b_.getInt8PtrTy(), true),
271+ b_.CreateIntCast(lookup, b_.getPtrTy(), true),
272 ConstantExpr::getCast(Instruction::IntToPtr,
273 b_.getInt64(0),
274- b_.getInt8PtrTy()),
275+ b_.getPtrTy()),
276 "map_lookup_cond");
277 b_.CreateCondBr(condition, lookup_success_block, lookup_failure_block);
278
279@@ -687,7 +687,7 @@ void CodegenLLVM::visit(Call &call)
280 ? Instruction::BitCast
281 : Instruction::IntToPtr,
282 expr_,
283- b_.getInt8PtrTy()),
284+ b_.getPtrTy()),
285 call.loc);
286 expr_ = buf;
287 expr_deleter_ = [this, buf]() { b_.CreateLifetimeEnd(buf); };
288@@ -919,9 +919,9 @@ void CodegenLLVM::visit(Call &call)
289
290 // and finally the seq_printf call
291 b_.CreateSeqPrintf(ctx_,
292- b_.CreateIntToPtr(fmt, b_.getInt8PtrTy()),
293+ b_.CreateIntToPtr(fmt, b_.getPtrTy()),
294 b_.getInt32(size),
295- b_.CreatePointerCast(data, b_.getInt8PtrTy()),
296+ b_.CreatePointerCast(data, b_.getPtrTy()),
297 b_.getInt32(data_size),
298 call.loc);
299
300@@ -950,7 +950,7 @@ void CodegenLLVM::visit(Call &call)
301 values.push_back(expr_);
302 }
303
304- b_.CreateTracePrintk(b_.CreateIntToPtr(fmt, b_.getInt8PtrTy()),
305+ b_.CreateTracePrintk(b_.CreateIntToPtr(fmt, b_.getPtrTy()),
306 b_.getInt32(size),
307 values,
308 call.loc);
309@@ -1878,7 +1878,7 @@ void CodegenLLVM::visit(FieldAccess &acc)
310 // `is_data_loc` should only be set if field access is on `args` which
311 // has to be a ctx access
312 assert(type.IsCtxAccess());
313- assert(ctx_->getType() == b_.getInt8PtrTy());
314+ assert(ctx_->getType() == b_.getPtrTy());
315 // Parser needs to have rewritten field to be a u64
316 assert(field.type.IsIntTy());
317 assert(field.type.GetIntBitWidth() == 64);
318@@ -2416,7 +2416,7 @@ void CodegenLLVM::createRet(Value *value)
319 void CodegenLLVM::visit(Probe &probe)
320 {
321 FunctionType *func_type = FunctionType::get(b_.getInt64Ty(),
322- { b_.getInt8PtrTy() }, // struct
323+ { b_.getPtrTy() }, // struct
324 // pt_regs
325 // *ctx
326 false);
327@@ -3773,7 +3773,7 @@ Function *CodegenLLVM::createMapLenCallback()
328 auto saved_ip = b_.saveIP();
329
330 std::array<llvm::Type *, 4> args = {
331- b_.getInt8PtrTy(), b_.getInt8PtrTy(), b_.getInt8PtrTy(), b_.getInt8PtrTy()
332+ b_.getPtrTy(), b_.getPtrTy(), b_.getPtrTy(), b_.getPtrTy()
333 };
334
335 FunctionType *callback_type = FunctionType::get(b_.getInt64Ty(), args, false);
336--
3372.43.2
338