Skip to content

Commit 63965f1

Browse files
committed
Update IR
IR commit: 02909bc123845fc2c41ec333b44b6f5ea1a196fe
1 parent fa21fce commit 63965f1

File tree

8 files changed

+31
-12
lines changed

8 files changed

+31
-12
lines changed

ext/opcache/jit/ir/ir.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,12 @@ static void ir_grow_top(ir_ctx *ctx)
348348
memset(ctx->use_lists + old_insns_limit, 0,
349349
(ctx->insns_limit - old_insns_limit) * sizeof(ir_use_list));
350350
}
351+
352+
if (ctx->cfg_map) {
353+
ctx->cfg_map = ir_mem_realloc(ctx->cfg_map, ctx->insns_limit * sizeof(uint32_t));
354+
memset(ctx->cfg_map + old_insns_limit, 0,
355+
(ctx->insns_limit - old_insns_limit) * sizeof(uint32_t));
356+
}
351357
}
352358

353359
static ir_ref ir_next_insn(ir_ctx *ctx)

ext/opcache/jit/ir/ir.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ extern "C" {
2929
# endif
3030
/* Only supported is little endian for any arch on Windows,
3131
so just fake the same for all. */
32-
# define __ORDER_LITTLE_ENDIAN__ 1
32+
# ifndef __ORDER_LITTLE_ENDIAN__
33+
# define __ORDER_LITTLE_ENDIAN__ 1
34+
# endif
3335
# define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
3436
# ifndef __has_builtin
3537
# define __has_builtin(arg) (0)
@@ -958,10 +960,12 @@ IR_ALWAYS_INLINE void *ir_jit_compile(ir_ctx *ctx, int opt_level, size_t *size)
958960
|| !ir_mem2ssa(ctx)) {
959961
return NULL;
960962
}
963+
if (opt_level > 1) {
964+
ir_reset_cfg(ctx);
965+
}
961966
}
962967

963968
if (opt_level > 1) {
964-
ir_reset_cfg(ctx);
965969
if (!ir_sccp(ctx)) {
966970
return NULL;
967971
}

ext/opcache/jit/ir/ir_aarch64.dasc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ binop_fp:
925925
if (ctx->flags & IR_FUNCTION) {
926926
ctx->flags |= IR_USE_FRAME_POINTER;
927927
}
928-
ctx->flags2 |= IR_HAS_CALLS | IR_16B_FRAME_ALIGNMENT;
928+
ctx->flags2 |= IR_HAS_CALLS;
929929
return IR_CALL;
930930
case IR_VAR:
931931
return IR_SKIPPED | IR_VAR;
@@ -941,7 +941,7 @@ binop_fp:
941941
}
942942
}
943943
ctx->flags |= IR_USE_FRAME_POINTER;
944-
ctx->flags2 |= IR_HAS_ALLOCA | IR_16B_FRAME_ALIGNMENT;
944+
ctx->flags2 |= IR_HAS_ALLOCA;
945945
}
946946
return IR_ALLOCA;
947947
case IR_LOAD:
@@ -5788,12 +5788,12 @@ void ir_fix_stack_frame(ir_ctx *ctx)
57885788
ctx->stack_frame_alignment = 0;
57895789
ctx->call_stack_size = 0;
57905790

5791-
if ((ctx->flags2 & IR_16B_FRAME_ALIGNMENT) && !(ctx->flags & IR_FUNCTION)) {
5791+
if (!(ctx->flags & IR_FUNCTION)) {
57925792
while (IR_ALIGNED_SIZE(ctx->stack_frame_size, 16) != ctx->stack_frame_size) {
57935793
ctx->stack_frame_size += sizeof(void*);
57945794
ctx->stack_frame_alignment += sizeof(void*);
57955795
}
5796-
} else if (ctx->flags2 & IR_16B_FRAME_ALIGNMENT) {
5796+
} else {
57975797
/* Stack must be 16 byte aligned */
57985798
if (!(ctx->flags & IR_FUNCTION)) {
57995799
while (IR_ALIGNED_SIZE(ctx->stack_frame_size, 16) != ctx->stack_frame_size) {

ext/opcache/jit/ir/ir_builder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ extern "C" {
461461
#define ir_COND_A(_op1, _op2, _op3) ir_fold3(_ir_CTX, IR_OPT(IR_COND, IR_ADDR), (_op1), (_op2), (_op3))
462462
#define ir_COND_C(_op1, _op2, _op3) ir_fold3(_ir_CTX, IR_OPT(IR_COND, IR_CHAR), (_op1), (_op2), (_op3))
463463
#define ir_COND_I8(_op1, _op2, _op3) ir_fold3(_ir_CTX, IR_OPT(IR_COND, IR_I8), (_op1), (_op2), (_op3))
464-
#define ir_COND_I16(_op1, _op2, _op3) ir_fold3(_ir_CTX, IR_OPT(IR_COMD, IR_I16), (_op1), (_op2), (_op3))
464+
#define ir_COND_I16(_op1, _op2, _op3) ir_fold3(_ir_CTX, IR_OPT(IR_COND, IR_I16), (_op1), (_op2), (_op3))
465465
#define ir_COND_I32(_op1, _op2, _op3) ir_fold3(_ir_CTX, IR_OPT(IR_COND, IR_I32), (_op1), (_op2), (_op3))
466466
#define ir_COND_I64(_op1, _op2, _op3) ir_fold3(_ir_CTX, IR_OPT(IR_COND, IR_I64), (_op1), (_op2), (_op3))
467467
#define ir_COND_D(_op1, _op2, _op3) ir_fold3(_ir_CTX, IR_OPT(IR_COND, IR_DOUBLE), (_op1), (_op2), (_op3))

ext/opcache/jit/ir/ir_cfg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ int ir_build_cfg(ir_ctx *ctx)
9292
uint32_t len = ir_bitset_len(ctx->insns_count);
9393
ir_bitset bb_starts = ir_mem_calloc(len * 2, IR_BITSET_BITS / 8);
9494
ir_bitset bb_leaks = bb_starts + len;
95-
_blocks = ir_mem_calloc(ctx->insns_count, sizeof(uint32_t));
95+
_blocks = ir_mem_calloc(ctx->insns_limit, sizeof(uint32_t));
9696
ir_worklist_init(&worklist, ctx->insns_count);
9797

9898
/* First try to perform backward DFS search starting from "stop" nodes */

ext/opcache/jit/ir/ir_check.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ bool ir_check(const ir_ctx *ctx)
291291
ok = 0;
292292
}
293293
break;
294+
case IR_PARAM:
295+
if (i > 2 && ctx->ir_base[i - 1].op != IR_PARAM) {
296+
fprintf(stderr, "ir_base[%d].op PARAMs must be used only right after START\n", i);
297+
ok = 0;
298+
}
299+
break;
294300
}
295301

296302
if (ctx->use_lists) {

ext/opcache/jit/ir/ir_emit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,10 @@ static bool ir_is_same_mem_var(const ir_ctx *ctx, ir_ref r1, int32_t offset)
272272

273273
void *ir_resolve_sym_name(const char *name)
274274
{
275-
void *handle = NULL;
276275
void *addr;
277276

278277
#ifndef _WIN32
278+
void *handle = NULL;
279279
# ifdef RTLD_DEFAULT
280280
handle = RTLD_DEFAULT;
281281
# endif

ext/opcache/jit/ir/ir_private.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,10 @@ IR_ALWAYS_INLINE uint32_t ir_ntz(uint32_t num)
137137
/* Number of trailing zero bits (0x01 -> 0; 0x40 -> 6; 0x00 -> LEN) */
138138
IR_ALWAYS_INLINE uint32_t ir_ntzl(uint64_t num)
139139
{
140-
#if (defined(__GNUC__) || __has_builtin(__builtin_ctzl))
141-
return __builtin_ctzl(num);
142-
#elif defined(_WIN64)
140+
// Note that the _WIN64 case should come before __has_builtin() below so that
141+
// clang-cl on Windows will use the uint64_t version, not the "long" uint32_t
142+
// version.
143+
#if defined(_WIN64)
143144
unsigned long index;
144145

145146
if (!_BitScanForward64(&index, num)) {
@@ -148,6 +149,8 @@ IR_ALWAYS_INLINE uint32_t ir_ntzl(uint64_t num)
148149
}
149150

150151
return (uint32_t) index;
152+
#elif (defined(__GNUC__) || __has_builtin(__builtin_ctzl))
153+
return __builtin_ctzl(num);
151154
#else
152155
uint32_t n;
153156

0 commit comments

Comments
 (0)