Skip to content

Commit

Permalink
fix: Fixed some integer conversions in the optimization function
Browse files Browse the repository at this point in the history
  • Loading branch information
NickyBoy89 committed Oct 21, 2024
1 parent 952a459 commit e6ff2e9
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,54 +753,52 @@ optimizations(int nr)
case '1':
dataflow = 1 - dataflow; /* dataflow */
if (verbose&32)
printf("spin: dataflow optimizations turned %s\n",
dataflow?"on":"off");
break;
case '2':
printf("spin: dataflow optimizations turned %s\n",
dataflow?"on":"off");
break;
case '2':
/* dead variable elimination */
deadvar = 1 - deadvar;
if (verbose&32)
printf("spin: dead variable elimination turned %s\n",
deadvar?"on":"off");
break;
printf("spin: dead variable elimination turned %s\n",
deadvar?"on":"off");
break;
case '3':
/* statement merging */
merger = 1 - merger;
if (verbose&32)
printf("spin: statement merging turned %s\n",
merger?"on":"off");
break;

break;
case '4':
/* rv optimization */
rvopt = 1 - rvopt;
if (verbose&32)
printf("spin: rendezvous optimization turned %s\n",
rvopt?"on":"off");
break;
break;
case '5':
/* case caching */
ccache = 1 - ccache;
if (verbose&32)
printf("spin: case caching turned %s\n",
ccache?"on":"off");
break;
printf("spin: case caching turned %s\n",
ccache?"on":"off");
break;
case '6':
old_priority_rules = 1;
if (verbose&32)
printf("spin: using old priority rules (pre version 6.2)\n");
return 0; /* no break */
printf("spin: using old priority rules (pre version 6.2)\n");
return 0; /* no break */
case '7':
implied_semis = 0;
if (verbose&32)
printf("spin: no implied semi-colons (pre version 6.3)\n");
return 0; /* no break */
printf("spin: no implied semi-colons (pre version 6.3)\n");
return 0; /* no break */
default:
printf("spin: bad or missing parameter on -o\n");
// usage();
break;
return -1; // TODO: Improve the failure mode for argument parsing
}
return 1;

return 0;
}

static void
Expand Down Expand Up @@ -1004,7 +1002,14 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
}
case 'n': args->T = atoi(arg); tl_terse = 1; break;
case 'O': old_scope_rules = 1; break;
case 'o': args->usedopts += optimizations(atoi(arg)); break;
case 'o': {
args->usedopts += optimizations(arg[0]);
if (args->usedopts == -1) {
argp_failure(state, 0, 1, "bad or missing parameter on -o: %d", atoi(arg));
return EINVAL;
}
break;
}
case 'P': {
assert(strlen(arg) < sizeof(PreProc));
strcpy(PreProc, arg);
Expand Down

0 comments on commit e6ff2e9

Please sign in to comment.