Skip to content

Commit c8cb9d5

Browse files
committed
Preserve none fixes
1 parent 3dd8dd5 commit c8cb9d5

File tree

2 files changed

+34
-27
lines changed

2 files changed

+34
-27
lines changed

ext/opcache/jit/ir/ir_ra.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4100,17 +4100,24 @@ static void assign_regs(ir_ctx *ctx)
41004100
} while (ival);
41014101
}
41024102

4103+
ir_regset preserved;
4104+
if (ctx->flags & IR_PRESERVE_NONE_FUNC) {
4105+
preserved = IR_REGSET_PNPRESERVED;
4106+
} else {
4107+
preserved = IR_REGSET_PRESERVED;
4108+
}
4109+
41034110
if (ctx->fixed_stack_frame_size != -1) {
41044111
ctx->used_preserved_regs = (ir_regset)ctx->fixed_save_regset;
4105-
if (IR_REGSET_DIFFERENCE(IR_REGSET_INTERSECTION(used_regs, IR_REGSET_PRESERVED),
4112+
if (IR_REGSET_DIFFERENCE(IR_REGSET_INTERSECTION(used_regs, preserved),
41064113
ctx->used_preserved_regs)) {
41074114
// TODO: Preserved reg and fixed frame conflict ???
41084115
// IR_ASSERT(0 && "Preserved reg and fixed frame conflict");
41094116
}
41104117
} else {
41114118
ctx->used_preserved_regs = IR_REGSET_UNION((ir_regset)ctx->fixed_save_regset,
4112-
IR_REGSET_DIFFERENCE(IR_REGSET_INTERSECTION(used_regs, IR_REGSET_PRESERVED),
4113-
(ctx->flags & IR_FUNCTION) ? (ir_regset)ctx->fixed_regset : IR_REGSET_PRESERVED));
4119+
IR_REGSET_DIFFERENCE(IR_REGSET_INTERSECTION(used_regs, preserved),
4120+
(ctx->flags & IR_FUNCTION) ? (ir_regset)ctx->fixed_regset : preserved));
41144121
}
41154122

41164123
ir_fix_stack_frame(ctx);

ext/opcache/jit/ir/ir_x86.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ enum _ir_reg {
156156
# define IR_REG_FP_RET1 IR_REG_XMM0
157157
# define IR_REG_INT_ARGS 6
158158
# define IR_REG_FP_ARGS 8
159+
# define IR_MAX_REG_ARGS 20 /* IR_REG_INT_PNARGS + IR_REG_FP_ARGS */
159160
# define IR_REG_INT_ARG1 IR_REG_RDI
160161
# define IR_REG_INT_ARG2 IR_REG_RSI
161162
# define IR_REG_INT_ARG3 IR_REG_RDX
@@ -190,37 +191,36 @@ enum _ir_reg {
190191
| IR_REGSET(IR_REG_RCX) | IR_REGSET(IR_REG_R8) | IR_REGSET(IR_REG_R9) \
191192
| IR_REGSET_INTERVAL(IR_REG_XMM0, IR_REG_XMM7))
192193

193-
# if __has_attribute(preserve_none)
194-
195-
# define IR_HAVE_PRESERVE_NONE 1
194+
# define IR_HAVE_PRESERVE_NONE 1
196195

197196
/* https://github.com/llvm/llvm-project/blob/68bfe91b5a34f80dbcc4f0a7fa5d7aa1cdf959c2/llvm/lib/Target/X86/X86CallingConv.td#L1029 */
198-
# define IR_REG_INT_PNARGS 12
199-
# define IR_REG_INT_PNARG1 IR_REG_R12
200-
# define IR_REG_INT_PNARG2 IR_REG_R13
201-
# define IR_REG_INT_PNARG3 IR_REG_R14
202-
# define IR_REG_INT_PNARG4 IR_REG_R15
203-
# define IR_REG_INT_PNARG5 IR_REG_RDI
204-
# define IR_REG_INT_PNARG6 IR_REG_RSI
205-
# define IR_REG_INT_PNARG7 IR_REG_RDX
206-
# define IR_REG_INT_PNARG8 IR_REG_RCX
207-
# define IR_REG_INT_PNARG9 IR_REG_R8
208-
# define IR_REG_INT_PNARG10 IR_REG_R9
209-
# define IR_REG_INT_PNARG11 IR_REG_R11
210-
# define IR_REG_INT_PNARG12 IR_REG_RAX
211-
212-
# define IR_MAX_REG_ARGS 20 /* IR_REG_INT_PNARGS + IR_REG_FP_ARGS */
213-
214-
# define IR_REGSET_PNARGS \
197+
# define IR_REG_INT_PNARGS 12
198+
# define IR_REG_INT_PNARG1 IR_REG_R12
199+
# define IR_REG_INT_PNARG2 IR_REG_R13
200+
# define IR_REG_INT_PNARG3 IR_REG_R14
201+
# define IR_REG_INT_PNARG4 IR_REG_R15
202+
# define IR_REG_INT_PNARG5 IR_REG_RDI
203+
# define IR_REG_INT_PNARG6 IR_REG_RSI
204+
# define IR_REG_INT_PNARG7 IR_REG_RDX
205+
# define IR_REG_INT_PNARG8 IR_REG_RCX
206+
# define IR_REG_INT_PNARG9 IR_REG_R8
207+
# define IR_REG_INT_PNARG10 IR_REG_R9
208+
# define IR_REG_INT_PNARG11 IR_REG_R11
209+
# define IR_REG_INT_PNARG12 IR_REG_RAX
210+
211+
/* https://github.com/llvm/llvm-project/blob/68bfe91b5a34f80dbcc4f0a7fa5d7aa1cdf959c2/llvm/lib/Target/X86/X86CallingConv.td#L1183 */
212+
# define IR_REGSET_PNPRESERVED IR_REGSET(IR_REG_RBP)
213+
214+
# define IR_REGSET_PNSCRATCH \
215+
(IR_REGSET_DIFFERENCE(IR_REGSET_INTERVAL(IR_REG_GP_FIRST, IR_REG_GP_LAST), IR_REGSET_PNPRESERVED) \
216+
| IR_REGSET_FP)
217+
218+
# define IR_REGSET_PNARGS \
215219
(IR_REGSET_INTERVAL(IR_REG_R12, IR_REG_R15) | IR_REGSET(IR_REG_RDI) \
216220
| IR_REGSET(IR_REG_RSI) | IR_REGSET(IR_REG_RDX) | IR_REGSET(IR_REG_RCX) \
217221
| IR_REGSET(IR_REG_R8) | IR_REGSET(IR_REG_R9) | IR_REGSET(IR_REG_R11) \
218222
| IR_REGSET(IR_REG_RAX) | IR_REGSET_INTERVAL(IR_REG_XMM0, IR_REG_XMM7))
219223

220-
# else /* !preserve_none */
221-
# define IR_MAX_REG_ARGS 14 /* IR_REG_INT_ARGS + IR_REG_FP_ARGS */
222-
# endif
223-
224224
typedef struct _ir_va_list {
225225
uint32_t gp_offset;
226226
uint32_t fp_offset;

0 commit comments

Comments
 (0)