Skip to content

Perform reductions that C-Reduce misses #2

@afd

Description

@afd

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).

  • [ ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions