There is the project VIXL (https://git.linaro.org/arm/vixl.git), AArch32 and AArch64 Runtime Code Generation Library. The library is used by such projects as AOSP and HHVM. The library has C++ sources which trigger quadratic running time in MemorySSA.
For example, the compilation time of https://git.linaro.org/arm/vixl.git/tree/test/aarch32/test-assembler-cond-rd-operand-rn-in-it-block-t32.cc is 5 minutes. G++ 5.4 compiles it in 17 seconds. The file contains a big global array of structs for which an initialiser is generated. The issue was found by Google. At the moment a workaround to turn optimisations off for the sources is used: https://android.googlesource.com/platform/external/vixl/+/master/test/aarch32/test-utils-aarch32.h.
This patch is a prototype of caching some results in ClobberWalker. The idea of caching is based on a pattern I have seen. When there is a walk path leading to a LiveOnEntry MemoryDef its result can be reused as soon as we get on the path again.
The patch reduces the compilation time from 5 minutes to 25 seconds.
Command to reproduce:
clang++ -c -Wall -Werror -fdiagnostics-show-option -Wextra -Wredundant-decls -pedantic -Wwrite-strings -Wunused -DVIXL_INCLUDE_TARGET_A32 -DVIXL_INCLUDE_TARGET_T32 -DVIXL_INCLUDE_TARGET_A64 -O3 -DVIXL_CODE_BUFFER_MMAP -DVIXL_INCLUDE_SIMULATOR_AARCH64 -Wmissing-noreturn -Wunreachable-code -Wno-long-long -Wno-variadic-macros -Isrc -Itest test/aarch32/test-assembler-cond-rd-operand-rn-in-it-block-t32.cc
Testing results:
- check-all passed
- VIXL tests passed
- Bootstrapped clang
- check-all passed
- VIXL tests passed
If we end up going forward with this, please make caching optional, so that we can have an EXPENSIVE_CHECKS assert to verify that we get the same result with/without our cache (without dropping our cache), as we did before.