Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perform reductions that C-Reduce misses #2

Open
2 tasks
afd opened this issue Dec 10, 2023 · 0 comments
Open
2 tasks

Perform reductions that C-Reduce misses #2

afd opened this issue Dec 10, 2023 · 0 comments

Comments

@afd
Copy link
Member

afd commented Dec 10, 2023

Here is a fully-reduced program for mutant 11782 of InstCombine:

#include <stdint.h>
#include <stdio.h>
uint32_t e[6];
uint32_t f = 5;
struct {
  unsigned o;
} p[1][1][7];
void a(uint32_t c, int d) { printf("%X\n", c); }
void g(uint8_t b) { f = f & 5 ^ e[(f ^ b) & 5]; }
void q(uint64_t l) { g(l); }
void m(uint64_t l, char *n, int d) { q(l); }
int main() {
  int i, j, k, r = j = 8;
  for (; j; j--)
    ;
  for (i = k = 0; k < 7; k++)
    m(p[i][j][k].o, "", r);
  a(f, r);
}

It can be manually reduced to this:

#include <stdint.h>
#include <stdio.h>
uint32_t e[6];
uint32_t f = 5;
struct {
  unsigned o;
} p[1][1][7];
void g(uint8_t b) { f = f & 5 ^ e[(f ^ b) & 5]; }
int main() {
  int i, j, k = j = 8;
  for (; j; j--)
    ;
  for (i = k = 0; k < 7; k++)
    g(p[i][j][k].o);
  printf("%X\n", f);
}

Consider the following custom reductions:

  • Removing parameters from functions and at all call sites

  • Inlining single-line functions (or, even, whole function bodies)

Then, re-running C-Reduce will hopefully yield final cleanup (removing unused function bodies and unused variables).

  • [ ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant