JustArchi's ArchiDroid Android Optimizations

This is the squashed commit of countless hours spent on trying to optimize Android to the maximum and push it to the limits.

Original author: Łukasz "JustArchi" Domeradzki, JustArchi@JustArchi.net, for "ArchiDroid" project

Please give proper credit if you decide to cherry-pick this commit. It includes countless number of full builds and tests, almost 100 hours spent on compiling and testing

WARNING! These modifcations are pretty DANGEROUS and shouldn't be commited to any official ROM, unless you know what you're doing! You're applying them on your own risk!

Pre-requirments:
- GCC 4.8, both androideabi and armeabi, these can be added to roomservice.xml from official google's repo, check platform/prebuilts/gcc/linux-x86/arm
- Turning off unknown flags error in android_frameworks_rs, includes changing -Werror to -Wno-error in Android.mk and cpu_ref/Android.mk -> JustArchi/android_frameworks_rs@525af84
- (Optional) Target user, instead of userdebug. With this commit you can use command such as "brunch i9300 user" instead of standard "brunch i9300", but this can be obtained through many ways.

Important changes:
- Disabled debugging for user builds. Notice: You should build with build variant user instead of userdebug, as user variant f.e. enables odexing, this change only involes turning on ADB by default, if you build userdebug nothing is changed, as it already includes this
- Updated GCC to 4.8, as it performs much better than default 4.7
- Moved branches with loop invariant conditions out of the loop (-funswitch-loops)
- Attempted to avoid false dependencies in scheduled code by making use of registers left over after register allocation. This optimization most benefits processors with lots of registers (-frename-registers)
- Re-ran common subexpression elimination after loop optimizations are performed (-frerun-cse-after-loop)
- Didn't keep the frame pointer in a register for functions that don't need one. This avoids the instructions to save, set up and restore frame pointers; it also makes an extra register available in many functions (-fomit-frame-pointer)
- Made a redundant load elimination pass performed after reload. The purpose of this pass is to clean up redundant spilling (-fgcse-after-reload)
- Ran a store motion pass after global common subexpression elimination. This pass attempts to move stores out of loops (-fgcse-sm)
- Eliminated redundant loads that come after stores to the same memory location, both partial and full redundancies (-fgcse-las)
- Constructed webs as commonly used for register allocation purposes and assigned each web individual pseudo register. This allows the register allocation pass to operate on pseudos directly, but also strengthens several other optimization passes, such as CSE, loop optimizer and trivial dead code remover (-fweb)
- Performed tail duplication to enlarge superblock size. This transformation simplifies the control flow of the function allowing other optimizations to do a better job (-ftracer)
- Removed all debugging code from executables (-DNDEBUG)
- Optimized GNU linker, which significantly reduces launching time and memory usage. This is especially visible during booting process, which is a few seconds faster than usual (-Wl,-O1)
- Applied special --as-needed flag to GNU linker. The flag tells the linker to link in the produced binary only the libraries containing symbols actually used by the binary itself. This not only improves startup times (as the loader does not have to load all the libraries for every step) but might avoid the full initialization of things, which we're not even physically able to use (-Wl,--as-needed)
- Performed global optimizations that become possible when the linker resolves addressing in the program, such as relaxing address modes and synthesizing new instructions in the output object file (-Wl,--relax)
- Sorted the common symbols by alignment in descending order. This is to prevent gaps between symbols due to alignment constraints (-Wl,--sort-common)
- Optimized yet more ARM instructions (-O3)
- Allowed the compiler to assume the strictest aliasing rules applicable to the language being compiled. For C (and C++), this activates optimizations based on the type of expressions. In particular, an object of one type is assumed never to reside at the same address as an object of a different type, unless the types are almost the same. This is only applied to compatible Android parts (-fstrict-aliasing)

BROKEN FLAGS: fipa-pta -fmodulo-sched -fmodulo-sched-allow-regmoves -ftree-parallelize-loops=n

-fipa-pta -> Compiles without problems but causes weird audio problems. From fast overview it looks like 48 KHz sounds are played 2-3 times faster.
This is observed for example with default "Pixie Dust" notification sound

-fgraphite -fgraphite-identity -floop-block -floop-flatten -floop-interchange -floop-strip-mine -floop-parallelize-all -ftree-loop-linear -> sorry, unimplemented: Graphite loop optimizations cannot be used

-fmodulo-sched -fmodulo-sched-allow-regmoves -> Causes segmentation faults in:
external/tremolo/Tremolo/res012.c: In function 'res_inverse': external/tremolo/Tremolo/res012.c:243:1: internal compiler error: Segmentation fault

-ftree-parallelize-loops=n -> Causes segmentation faults in:
system/core/include/utils/Vector.h: In member function 'void android::Vector<TYPE>::do_construct(...)': system/core/include/utils/Vector.h:389:6: internal compiler error: Segmentation fault