{"push_id":760375224,"size":1,"distinct_size":1,"ref":"refs/heads/cm-12.1","head":"bda45593c6c11aa0b27d90dfcb8ee56669f8f33e","before":"842cd35915a031145bd226d9041561f3f9352842","commits":[{"sha":"bda45593c6c11aa0b27d90dfcb8ee56669f8f33e","author":{"email":"3be945bfeeebacf832ea217f2164100306661e3a@JustArchi.net","name":"Łukasz Domeradzki"},"message":"JustArchi's ArchiDroid Optimizations V4.1\n\n     _             _     _ ____            _     _\n    / \\   _ __ ___| |__ (_)  _ \\ _ __ ___ (_) __| |\n   / _ \\ | '__/ __| '_ \\| | | | | '__/ _ \\| |/ _` |\n  / ___ \\| | | (__| | | | | |_| | | | (_) | | (_| |\n /_/   \\_\\_|  \\___|_| |_|_|____/|_|  \\___/|_|\\__,_|\n\nCopyright (C) 2015 Łukasz \"JustArchi\" Domeradzki\n----------------------------------------------------------------------------------------------------------------\nThis is the squashed commit of countless hours spent on trying to optimize Android to the maximum and push it to the limits.\nPlease give proper credit if you decide to cherry-pick this commit. It includes countless number of full builds and tests, almost 200 hours (KK), and additional 100 hours (LP) spent on compiling and testing\n----------------------------------------------------------------------------------------------------------------\nWARNING! These modifcations are pretty DANGEROUS and may cause problems during compiling or running. You may also need to implement some fixes on your own.\n----------------------------------------------------------------------------------------------------------------\nPre-requirements:\n- GCC 4.8+, both androideabi and armeabi. Fortunately for us, Lollipop already uses GCC 4.8, but it's in outdated versions and has some internal compiler errors with O3 flags this commit applies. Therefore, I suggest:\n1. UBERTC 4.9 arm-linux-androideabi -> https://github.com/ArchiDroid/Toolchain/tree/uber-4.9-arm-linux-androideabi\n2. ArchiToolchain 4.9 arm-eabi -> https://github.com/ArchiDroid/Toolchain/tree/architoolchain-4.9-arm-linux-gnueabi-generic\n(Please notice that ArchiToolchain is available in many variants, you may want to select the one that suits you best, e.g. Cortex A9 onex)\n\n- (Optional) Target user, instead of userdebug. You should build with user variant instead of userdebug, as user variant in general pre-optimizes some parts and disables additional debug modules, i.e. dalvik debugging, procmem/procrank binaries and so.\nThis can be done by multiple ways, e.g. using proper lunch command (i.e. lunching cm_i9300-user instead of cm_i9300-userdebug) or \"brunch device user\", such as \"brunch i9300 user\", if your android_build includes my CM commit -> https://github.com/CyanogenMod/android_build/commit/73db70d928f4a7af1d4a0a255327c6ff5d8ffbc9\n----------------------------------------------------------------------------------------------------------------\nImportant notes:\n- This commit has been tested on up-to-date CM-12.1 (Android 5.1.1) and suggested toolchains mentioned above. Other ROMs and toolchains may, or may not, work out of the box with it.\n- You can ask for help in such cases in the XDA thread linked on the bottom of the commit.\n- You're applying these optimizations at your own risk, I highly suggest to understand what each of the flag does, and not trying to blindly \"apply them all\" and hope for the best. Also, due to various hacks and issues in various trees and devices, I can't assure you that what works for me, will also work for you.\n- Fortunately for you, my test device is Samsung Galaxy S3 with the nightmare Exynos4 SoC, so it's likely that it should work for major of the (better done) devices.\n- As pointed in pre-requirements, stock AOSP toolchains are outdated and have many internal compiler errors. This commit probably can work on stock AOSP toolchains, but you'll need to get rid of some flags that are causing those errors on AOSP toolchains (e.g. -O3 for thumb)\n- Due to O3 optimization, code is significantly larger and may cause problems with oversized images especially for older devices. For example, I couldn't apply O3 because building TWRP recovery failed due to the fact that it didn't fit on recovery's block in my device. In such case you have two options. You can use my little hack that ignored recovery size, so compiler doesn't yell about that (but you obviously can't flash such images), or you need to go back either to O2 or Os (for thumb), up to you.\n----------------------------------------------------------------------------------------------------------------\nImportant changes:\n- Optimized for speed yet more all instructions - ARM and THUMB (-O3)\n- Optimized for speed also parts which are compiled with Clang (-O3)\n- Turned off all debugging code (lack of -g)\n- Eliminated redundant loads that come after stores to the same memory location, both partial and full redundancies (-fgcse-las)\n- Ran a store motion pass after global common subexpression elimination. This pass attempts to move stores out of loops (-fgcse-sm)\n- Enabled the identity transformation for graphite. For every SCoP we generate the polyhedral representation and transform it back to gimple. We can then check the costs or benefits of the GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations are also performed by the code generator ISL, like index splitting and dead code elimination in loops (-fgraphite -fgraphite-identity)\n- Performed interprocedural pointer analysis and interprocedural modification and reference analysis (-fipa-pta)\n- Performed induction variable optimizations (strength reduction, induction variable merging and induction variable elimination) on trees (-fivopts)\n- 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)\n- 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)\n- Tried to reduce the number of symbolic address calculations by using shared “anchor” symbols to address nearby objects. This transformation can help to reduce the number of GOT entries and GOT accesses on some targets (-fsection-anchors)\n- 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)\n- Performed loop invariant motion on trees. It also moved operands of conditions that are invariant out of the loop, so that we can use just trivial invariantness analysis in loop unswitching. The pass also includes store motion (-ftree-loop-im)\n- Created a canonical counter for number of iterations in loops for which determining number of iterations requires complicated analysis. Later optimizations then may determine the number easily (-ftree-loop-ivcanon)\n- Assumed that loop indices do not overflow, and that loops with nontrivial exit condition are not infinite. This enables a wider range of loop optimizations even if the loop optimizer itself cannot prove that these assumptions are valid (-funsafe-loop-optimizations)\n- Moved branches with loop invariant conditions out of the loop (-funswitch-loops)\n- 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)\n- Sorted the common symbols by alignment in descending order. This is to prevent gaps between symbols due to alignment constraints (-Wl,--sort-common)\n----------------------------------------------------------------------------------------------------------------\n\nFor more information, support, troubleshooting and discussion about my optimizations, please refer to my thread on XDA -> http://forum.xda-developers.com/showthread.php?t=2754997","distinct":true,"url":"https://api.github.com/repos/CM-L9/android_build/commits/bda45593c6c11aa0b27d90dfcb8ee56669f8f33e"}]}