A whirlwind tour of the LLVM optimizer

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • qbe-rs

    QBE IR in natural Rust data structures

    You might be underestimating the accuracy of the CPU models LLVM uses.

    For x86, the same data the code generator uses drives llvm-mca[1], which given a loop body can tell you the throughput, latency, and microarchitectural bottlenecks (decoding, ports, dependencies, store forwarding, etc.)—if not always precisely, then still not worse then IACA, the tool written at Intel by people who presumably knew how the CPUs work, unlike LLVM contributors and the rest of us who can only guess and measure. This separately for Haswell, Sandy Bridge, Skylake, etc.; not “x86”.

    Now, is this the best model you can get? Not exactly[2], but it’s close enough to not matter. Do we often need machine code to be optimized to that level of detail? Perhaps not[3], and with that in mind you can shave at least a factor of ten off LLVM’s considerable bulk at the cost of 20—30% of performance[4,5]. But if you do want those as well, it seems that the complexity of LLVM is a fair price, or has the right order of magnitude at least.

    (Frontend not included, C++ frontend required to bootstrap sold separately, at a similar markup compared to a C-only frontend with somewhat worse ergonomics.)

    [1] https://llvm.org/docs/CommandGuide/llvm-mca.html

    [2] https://www.uops.info/

    [3] https://briancallahan.net/blog/20211010.html

    [4] https://c9x.me/compile/

    [5] https://drewdevault.com/talks/qbe.html

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts