mirror of
https://github.com/danog/ir.git
synced 2024-12-02 09:38:29 +01:00
Fixed GH issue #33: IR program failed to compile with "-O0" "-S" options
This commit is contained in:
parent
b5bb5f869a
commit
186dc6b0a6
@ -716,6 +716,8 @@ binop_fp:
|
||||
return IR_CALL;
|
||||
case IR_VAR:
|
||||
return IR_SKIPPED | IR_VAR;
|
||||
case IR_PARAM:
|
||||
return ctx->use_lists[ref].count > 0 ? IR_PARAM : IR_SKIPPED | IR_PARAM;
|
||||
case IR_ALLOCA:
|
||||
if (ctx->flags & IR_FUNCTION) {
|
||||
ctx->flags |= IR_USE_FRAME_POINTER | IR_HAS_ALLOCA;
|
||||
|
6
ir_ra.c
6
ir_ra.c
@ -62,7 +62,7 @@ static int ir_assign_virtual_registers_slow(ir_ctx *ctx)
|
||||
insn += n;
|
||||
while (i < bb->end) {
|
||||
flags = ir_op_flags[insn->op];
|
||||
if (((flags & IR_OP_FLAG_DATA) && ctx->use_lists[i].count > 0)
|
||||
if (((flags & IR_OP_FLAG_DATA) && insn->op != IR_VAR && (insn->op != IR_PARAM || ctx->use_lists[i].count > 0))
|
||||
|| ((flags & IR_OP_FLAG_MEM) && ctx->use_lists[i].count > 1)) {
|
||||
if (!ctx->rules || !(ctx->rules[i] & (IR_FUSED|IR_SKIPPED))) {
|
||||
vregs[i] = ++vregs_count;
|
||||
@ -99,7 +99,7 @@ int ir_assign_virtual_registers(ir_ctx *ctx)
|
||||
if (ctx->rules[i] && !(ctx->rules[i] & (IR_FUSED|IR_SKIPPED))) {
|
||||
uint32_t flags = ir_op_flags[insn->op];
|
||||
|
||||
if (((flags & IR_OP_FLAG_DATA) && ctx->use_lists[i].count > 0)
|
||||
if ((flags & IR_OP_FLAG_DATA)
|
||||
|| ((flags & IR_OP_FLAG_MEM) && ctx->use_lists[i].count > 1)) {
|
||||
v = ++vregs_count;
|
||||
}
|
||||
@ -323,7 +323,7 @@ static ir_live_interval *ir_fix_live_range(ir_ctx *ctx, int v, ir_live_pos old_s
|
||||
p = p->next;
|
||||
}
|
||||
#endif
|
||||
IR_ASSERT(p && p->start == old_start);
|
||||
IR_ASSERT(ival && p->start == old_start);
|
||||
p->start = new_start;
|
||||
return ival;
|
||||
}
|
||||
|
@ -1365,6 +1365,8 @@ binop_fp:
|
||||
return insn->op;
|
||||
case IR_VAR:
|
||||
return IR_SKIPPED | IR_VAR;
|
||||
case IR_PARAM:
|
||||
return ctx->use_lists[ref].count > 0 ? IR_PARAM : IR_SKIPPED | IR_PARAM;
|
||||
case IR_ALLOCA:
|
||||
/* alloca() may be use only in functions */
|
||||
if (ctx->flags & IR_FUNCTION) {
|
||||
|
28
tests/bugs/gh-00033.irt
Normal file
28
tests/bugs/gh-00033.irt
Normal file
@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
GH-33: IR program failed to compile with "-O0" "-S" options
|
||||
--TARGET--
|
||||
x86_64
|
||||
--ARGS--
|
||||
-O0 -S
|
||||
--CODE--
|
||||
{
|
||||
uintptr_t c_1 = 0;
|
||||
bool c_2 = 0;
|
||||
bool c_3 = 1;
|
||||
int32_t c_4 = 10;
|
||||
l_1 = START(l_4);
|
||||
int32_t d_2 = PARAM(l_1, "x", 0);
|
||||
int32_t d_3 = DIV(d_2, c_4);
|
||||
l_4 = RETURN(l_1, null);
|
||||
}
|
||||
--EXPECT--
|
||||
test:
|
||||
subq $8, %rsp
|
||||
movl %edi, (%rsp)
|
||||
movl (%rsp), %eax
|
||||
movl $0xa, %ecx
|
||||
cltd
|
||||
idivl %ecx
|
||||
movl %eax, 4(%rsp)
|
||||
addq $8, %rsp
|
||||
retq
|
Loading…
Reference in New Issue
Block a user