*IR main operations
*/
+static bool ir_check_unreachable(ir_block *self)
+{
+ /* The IR should never have to deal with unreachable code */
+ if (!self->final/* || OPTS_FLAG(ALLOW_UNREACHABLE_CODE)*/)
+ return true;
+ irerror(self->context, "unreachable statement (%s)", self->label);
+ return false;
+}
+
bool ir_block_create_store_op(ir_block *self, lex_ctx ctx, int op, ir_value *target, ir_value *what)
{
ir_instr *in;
- if (self->final) {
- irerror(self->context, "unreachable statement (%s)", self->label);
+ if (!ir_check_unreachable(self))
return false;
- }
if (target->store == store_value &&
(op < INSTR_STOREP_F || op > INSTR_STOREP_FNC))
bool ir_block_create_return(ir_block *self, lex_ctx ctx, ir_value *v)
{
ir_instr *in;
- if (self->final) {
- irerror(self->context, "unreachable statement (%s)", self->label);
+ if (!ir_check_unreachable(self))
return false;
- }
self->final = true;
self->is_return = true;
in = ir_instr_new(ctx, self, INSTR_RETURN);
ir_block *ontrue, ir_block *onfalse)
{
ir_instr *in;
- if (self->final) {
- irerror(self->context, "unreachable statement (%s)", self->label);
+ if (!ir_check_unreachable(self))
return false;
- }
self->final = true;
/*in = ir_instr_new(ctx, self, (v->vtype == TYPE_STRING ? INSTR_IF_S : INSTR_IF_F));*/
in = ir_instr_new(ctx, self, VINSTR_COND);
bool ir_block_create_jump(ir_block *self, lex_ctx ctx, ir_block *to)
{
ir_instr *in;
- if (self->final) {
- irerror(self->context, "unreachable statement (%s)", self->label);
+ if (!ir_check_unreachable(self))
return false;
- }
self->final = true;
in = ir_instr_new(ctx, self, VINSTR_JUMP);
if (!in)
bool ir_block_create_goto(ir_block *self, lex_ctx ctx, ir_block *to)
{
ir_instr *in;
- if (self->final) {
- irerror(self->context, "unreachable statement (%s)", self->label);
+ if (!ir_check_unreachable(self))
return false;
- }
self->final = true;
in = ir_instr_new(ctx, self, INSTR_GOTO);
if (!in)
{
ir_value *out;
ir_instr *in;
- if (self->final) {
- irerror(self->context, "unreachable statement (%s)", self->label);
+ if (!ir_check_unreachable(self))
return false;
- }
in = ir_instr_new(ctx, self, VINSTR_PHI);
if (!in)
return NULL;
{
ir_value *out;
ir_instr *in;
- if (self->final) {
- irerror(self->context, "unreachable statement (%s)", self->label);
+ if (!ir_check_unreachable(self))
return false;
- }
in = ir_instr_new(ctx, self, (noreturn ? VINSTR_NRCALL : INSTR_CALL0));
if (!in)
return NULL;
opts_set(opts.flags, ADJUST_VECTOR_FIELDS, true);
opts_set(opts.flags, FTEPP, false);
opts_set(opts.flags, CORRECT_TERNARY, true);
+ opts_set(opts.flags, ALLOW_UNREACHABLE_CODE, true);
}
void opts_init(const char *output, int standard, size_t arraysize) {