GCC commits and patches

My GCC commits and patches

avr-gcc explorer

Run avr-gcc from your browser and compare generated code across versions

Why did the compiler do that - the one with VRP and integer size

Here’s a simple program - it right shifts a signed int by 9 bits, truncates it to an unsigned char, and returns 1 or 0 after comparing the result with 0x74. $ cat test.c extern int e; int main() { unsigned char result = e >> 9; // result = 0x74; if ((int)result != 0x74) return 1; return 0; } Let’s compile this for the avr target, choosing to optimize for size.

Thin LTO and compile time errors

GCC has had link time optimization (LTO) for quite a while now. Instead of generating just assembly code, it streams intermediate representation (IR) for the translation unit to the object file. At link time, when you provide all the object files necessary to link into the ELF, the compiler gets to see IR from all the translation units together, and this lets it perform optimizations across translation units. All you have to do is add -flto to the compiler and linker invocations and you’re done.

GCC's command line option handling and arbitrary values

Say you want to add your own command line option to the gcc driver. It’s pretty easy to do it as long as it is a number or a bitmask - just add an entry to your target’s opt file, and gcc’s option handling mechanism takes cares of it all. For example, this is how the avr target’s mn-flash option is described in avr.opt mn-flash= Target RejectNegative Joined Var(avr_n_flash) UInteger Init(-1) Set the number of 64 KiB flash segments.