c++ - C function to exercise as many registers as possible -
i'm writing test suite assembler stub on multiple cpu architectures. stub meant pass arguments c callback.
i have written tests cover multiple scenarios (eg passing struct value, mixing arguments of different native size, mixing float args ints etc) , test callback something use lots of registers/stack slots etc.
the idea try , flush out implementations working fluke (eg value not correctly put on stack, happens still in register away etc).
can recommend piece of c/c++ can use test here? realise register use varies wildly across architectures , there's no guarantee @ complete coverage, nice have gave reasonable amount of confidence. thanks
there nothing in c/c++ standards here. reliable way way compiler writers it. study code compiler generates , think ways break it.
having said that, can think of strategies might flush out common problems.
- make calls lots of different combinations of argument types , numbers. example, function single argument or return value char/short/int/long/float/double/pointer etc exercise range of compiler code generation (and passed in register if possible). same function lots of arguments use different strategy, , (in cases) not have enough registers.
- insert preamble code called function, passed in arguments not used registers filled other values.
- use variadic arguments. calling conventions variadic arguments (especially separate compile , link) virtually guarantee arguments on stack , not in registers.
- exercise lots of different call types: not simple scalars struct value, pointer function, pointer member, etc.
- cheat. call 1 prototype cast function pointer callee has different prototype. example, call double on stack callee function has 2 longs. requires inside knowledge of compiler workings.
the pre-written code find stuff compiler compliance suite chosen compiler.
breaking compilers fun. here it.
Comments
Post a Comment