TPDE: A Fast Adaptable Compiler Back-End Framework

by npallion 6/2/2025, 1:17 AMwith 15 comments

by npallion 6/2/2025, 3:57 AM

Source code for the framework

https://github.com/tpde2/tpde

by BarakWidawskyon 6/2/2025, 3:53 AM

If this is a faster backend for LLVM, does it potentially obviate the niche Cranelift is optimizing for?

by MaskRayon 6/3/2025, 7:34 AM

Build instructions

In the llvm/llvm-project repository

    git switch origin/release/19.x
    cmake -GNinja -S. -B/tmp/out/custom -DLLVM_TARGETS_TO_BUILD='X86;AArch64' -DLLVM_ENABLE_PROJECTS=clang -DLLVM_ENABLE_PLUGINS=off -DCMAKE_BUILD_TYPE=Release -DLLVM_LINK_LLVM_DYLIB=on
    # consider -DCLANG_ENABLE_OBJC_REWRITER=off -DCLANG_ENABLE_STATIC_ANALYZER=off -DCLANG_ENABLE_ARCMT=off -DCLANG_PLUGIN_SUPPORT=off
    ninja -C /tmp/out/custom clang LLVM FileCheck   # build clang and libLLVM.so and test utilities

In the tpde repository

    git submodule update --init
    cmake -GNinja -S. -Bout/debug -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=on -DCMAKE_PREFIX_PATH=/tmp/out/custom -DCMAKE_CXX_COMPILER=$HOME/Stable/bin/clang++ -DCMAKE_C_COMPILER=$HOME/Stable/bin/clang
/Stable/bin/clang

There are some failures:

``` % /tmp/out/custom/bin/llvm-lit out/debug/tpde/test/filetest ... Failed Tests (5): TPDE FileTests :: codegen/eh-frame-arm64.tir TPDE FileTests :: codegen/eh-frame-x64.tir TPDE FileTests :: codegen/simple_ret.tir TPDE FileTests :: codegen/tbz.tir TPDE FileTests :: tir/duplicate_funcs.tir ```

by xiphias2on 6/2/2025, 5:33 AM

It's great start, but what would be cooler if they really went through the boring part, which is putting it into LLVM as the new default -O0 compiler.

Edit: LLM to LLVM

by fookeron 6/2/2025, 10:08 AM

What makes this 'adaptable' and what makes this a 'framework'?

Seems like a pretty neat fast compiler backend for LLVM. Why the extra buzzwords?

by vlovich123on 6/2/2025, 5:21 AM

> Performance results on SPECint 2017 show that we can compile LLVM-IR 8--24x faster than LLVM -O0 while being on-par in terms of run-time performance

Wait - it’s 8-24x faster than O0 while producing code on par with O3???