How do I improve time and optimization quality in LLVM projects?

Hello everyone :slightly_smiling_face:

I am currently working on a project with LLVM and want to improve the speed and accuracy of my generator.
I am interested in methods for handling multiple optimisation stages and increasing the quality of code.

Could someone provide suggestions on the latest trends for putting into effect optimisation steps; as well as approaches for decreasing build time without sacrificing optimisation quality?

Thank you in advance :smiling_face_with_three_hearts:

As for decreasing build time, I have tested some commands as Build speed on different platforms. Some folks provided very good suggestions.

The default compiler to build LLVM is gcc and linker is ld, which will cost much memory and greatly decrease the speed when you are using swap space. By using clang and lld, the memory burden can be greatly released, which will increase the build speed. Also, clang is way more faster than old gcc.

The command I am using now is

CC=clang CXX=clang++ \
cmake -S llvm -B ./build -G "Ninja" \
  -DLLVM_TARGETS_TO_BUILD="X86;ARM;RISCV"  \
  -DLLVM_ENABLE_PROJECTS="clang;lld" \
  -DLLVM_ENABLE_ASSERTIONS=true      \
  -DCLANG_DEFAULT_PIE_ON_LINUX=OFF   \
  -DLLVM_USE_LINKER=lld \
  -DCMAKE_BUILD_TYPE=Debug