Testing 1, 2, 3…

I borrowed some bits from my 6502 GCC port to wire up the instruction-set simulator to GCC’s testsuite: there may be (probably are!) bugs in all of the simulator, binutils and GCC, but PASSes will mean they are all consistent with each other, which is something at least. I also fixed linking so it maps sections to segments (aka program headers) properly, which was a 1-line fix, but as ever, the hard part was figuring out why it wasn’t working to start with.

In GCC proper, register elimination (replacing offset frame pointer accesses with offset stack pointer accesses, etc.) is now working somewhat properly: it was broken for a long time because of a preprocessor misfeature: it turns out if you have something like,

#include <stdio.h>

enum bla {
  FIRST,
  SECOND
};

#define SOMETHING FIRST
#define OTHERTHING SECOND

int main(int argc, char* argv[])
{
  #if SOMETHING == OTHERTHING
  printf ("Boom!\n");
  #else
  printf ("This is what you might expect to execute\n");
  #endif
  return 0;
}

Then it compiles without warning, but the “Boom!” line is executed — the undefined identifiers FIRST and SECOND are both replaced with 0, since the preprocessor knows nothing about the enum. Anyway, in the real code, this meant that (via a similar #if condition) eliminations happened to the wrong register, leading to much confusion!

Oh, and (update) here are the initial results:

                === gcc Summary ===

# of expected passes            46281
# of unexpected failures        9307
# of unexpected successes       1
# of expected failures          94
# of unresolved testcases       7623
# of unsupported tests          1556

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>