On Fri, Nov 26, 2010 at 10:40:34AM -0800, Mark Mitchell wrote:
As an extension of that idea, and tying into the idea of optimizing for size, I suspect that we (a) ought be optimizing for size automatically in cold code, and (b) that we're probably not doing a great job of optimizing for size.
Somewhat OT, and I'm not sure this has been mentioned before, though I guess Mark has seen it:
http://embed.cs.utah.edu/embarrassing/
This group basically runs a set of size benchmarks against multiple compilers. I wonder how a) this would look for a survey of ARM compilers and b) if we could get them to run a benchmark for us if we provided them with hardware (and if not, if they'd provide us with the code).
Note also that the same group has a tool for generating random C code with volatiles which we could use for some level of validation:
http://www.cs.utah.edu/~eeide/emsoft08/
I've inlined below a sample program generated with randprog (you'll want to apt-get install libboost-program-options1.40-dev to build it):
---------------------------------------------------------------------- * This is a RANDOMLY GENERATED PROGRAM. * * Generator: randprog 1.0.0 * Options: (none) * Seed: 3881625688 */
#include <stdint.h> uint16_t context = 0;
#if defined(__AVR_ARCH__) # include "platform_avr.h" #elif defined (__MSP430__) # include "platform_msp430.h" #else # include "platform_generic.h" #endif
#include "random_runtime.h"
/* --- GLOBAL VARIABLES --- */ uint8_t g_4 = -4L;
/* --- FORWARD DECLARATIONS --- */ int32_t func_1(void);
/* --- FUNCTIONS --- */ /* ------------------------------------------ */ /* * reads : g_4 * writes: */ int32_t func_1(void) { { int8_t l_2 = 0L; for (l_2 = -1; (l_2 == 0); l_2 -= 0) { uint16_t l_3 = 1L; return l_3; } return g_4; } }
/* ---------------------------------------- */ int main(int argc, char *argv[]) { platform_main_begin(); /* Call the first function */ func_1(); crcBytes(g_4); platform_main_end(context); return 0; }