Skip to content

Commit 2085e2c

Browse files
committed
Fix GH-25169: avoid clobbering bound spill slots
Fixes #25169.
1 parent 3efb356 commit 2085e2c

7 files changed

Lines changed: 519 additions & 3 deletions

File tree

‎ext/opcache/jit/ir/ir.h‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,18 @@ ir_ref ir_var(ir_ctx *ctx, ir_type type, ir_ref region, const char *name);
934934
ir_ref ir_var_ex(ir_ctx *ctx, ir_type type, ir_ref region, ir_str name);
935935

936936
/* IR Binding */
937+
/*
938+
* A negative "var" binds "def" to the special spill slot at spill_base-var.
939+
* The register allocator keeps a value in its bound slot only while it sees no
940+
* conflicting access to that slot in the value's live range: a STORE or LOAD
941+
* that may address it, a CALL that receives a pointer derived from spill_base,
942+
* or an RSTORE of spill_base. Otherwise the value is spilled to an ordinary
943+
* slot, and code where that value is also live at an ENTRY is rejected with
944+
* IR_ERROR_BOUND_SLOT_CONFLICT. Writes it cannot see remain the caller's
945+
* responsibility: a callee that reaches the frame through the spill_base
946+
* register or a global, or through a frame pointer reloaded from memory, must
947+
* not write a bound slot while a value bound to it is live.
948+
*/
937949
ir_ref ir_bind(ir_ctx *ctx, ir_ref var, ir_ref def);
938950
ir_ref ir_binding_find(const ir_ctx *ctx, ir_ref ref);
939951

@@ -1198,6 +1210,7 @@ IR_ALWAYS_INLINE void *ir_jit_compile(ir_ctx *ctx, int opt_level, size_t *size)
11981210
#define IR_ERROR_LINK 4
11991211
#define IR_ERROR_ENCODE 5
12001212
#define IR_ERROR_TOO_LARGE 6
1213+
#define IR_ERROR_BOUND_SLOT_CONFLICT 7
12011214

12021215
/* IR Memmory Allocation */
12031216
#ifndef ir_mem_malloc

‎ext/opcache/jit/ir/ir_aarch64.dasc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9427,6 +9427,10 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
94279427
ir_ref igoto_dup_ref = IR_UNUSED;
94289428
uint32_t igoto_dup_block = 0;
94299429

9430+
if (ctx->status) {
9431+
return NULL;
9432+
}
9433+
94309434
memset(&data, 0, sizeof(data));
94319435
data.ra_data.cc = ir_get_call_conv_dsc(ctx->flags);
94329436
ctx->data = &data;

0 commit comments

Comments
 (0)