Skip to content

Commit 1d916d4

Browse files
committed
Preserve none fixes
1 parent a659661 commit 1d916d4

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
@@ -4098,17 +4098,24 @@ static void assign_regs(ir_ctx *ctx)
40984098
} while (ival);
40994099
}
41004100

4101+
ir_regset preserved;
4102+
if (ctx->flags & IR_PRESERVE_NONE_FUNC) {
4103+
preserved = IR_REGSET_PNPRESERVED;
4104+
} else {
4105+
preserved = IR_REGSET_PRESERVED;
4106+
}
4107+
41014108
if (ctx->fixed_stack_frame_size != -1) {
41024109
ctx->used_preserved_regs = (ir_regset)ctx->fixed_save_regset;
4103-
if (IR_REGSET_DIFFERENCE(IR_REGSET_INTERSECTION(used_regs, IR_REGSET_PRESERVED),
4110+
if (IR_REGSET_DIFFERENCE(IR_REGSET_INTERSECTION(used_regs, preserved),
41044111
ctx->used_preserved_regs)) {
41054112
// TODO: Preserved reg and fixed frame conflict ???
41064113
// IR_ASSERT(0 && "Preserved reg and fixed frame conflict");
41074114
}
41084115
} else {
41094116
ctx->used_preserved_regs = IR_REGSET_UNION((ir_regset)ctx->fixed_save_regset,
4110-
IR_REGSET_DIFFERENCE(IR_REGSET_INTERSECTION(used_regs, IR_REGSET_PRESERVED),
4111-
(ctx->flags & IR_FUNCTION) ? (ir_regset)ctx->fixed_regset : IR_REGSET_PRESERVED));
4117+
IR_REGSET_DIFFERENCE(IR_REGSET_INTERSECTION(used_regs, preserved),
4118+
(ctx->flags & IR_FUNCTION) ? (ir_regset)ctx->fixed_regset : preserved));
41124119
}
41134120

41144121
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
@@ -155,6 +155,7 @@ enum _ir_reg {
155155
# define IR_REG_FP_RET1 IR_REG_XMM0
156156
# define IR_REG_INT_ARGS 6
157157
# define IR_REG_FP_ARGS 8
158+
# define IR_MAX_REG_ARGS 20 /* IR_REG_INT_PNARGS + IR_REG_FP_ARGS */
158159
# define IR_REG_INT_ARG1 IR_REG_RDI
159160
# define IR_REG_INT_ARG2 IR_REG_RSI
160161
# define IR_REG_INT_ARG3 IR_REG_RDX
@@ -189,37 +190,36 @@ enum _ir_reg {
189190
| IR_REGSET(IR_REG_RCX) | IR_REGSET(IR_REG_R8) | IR_REGSET(IR_REG_R9) \
190191
| IR_REGSET_INTERVAL(IR_REG_XMM0, IR_REG_XMM7))
191192

192-
# if __has_attribute(preserve_none)
193-
194-
# define IR_HAVE_PRESERVE_NONE 1
193+
# define IR_HAVE_PRESERVE_NONE 1
195194

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

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

0 commit comments

Comments
 (0)