[llvm] [TTI][BPF]: Undo specific transform-preventing passes and add one TTI hook (PR #97073)

Yingchi Long via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 4 00:12:12 PDT 2024


inclyc wrote:

Hi @Spikhalskiy

> I personally don’t see many ways for us to solve our struggles with LLVM producing “unexpected” bytecode other than making a LLVM fork and applying the rejected patches.

Maybe, if you want your "bytecode" in a desired specific "shape", a solution is to write your source code as `asm volatile`.
It is somehow ugly, but actually give you the right to determine generated byte code.

> BPF target shouldn’t have rights to disqualify some types of transformations

That's indeed true, middle-end developers may want to canonicalize the IR in a "single/standard" form. Generally if the code is more canonicalized, the better optimization results we get. So generally it is not a good solution to interference that process, that's why TTI solutions like this may get rejected. Disabling some specific transforms in middle-end may result in very bad code generation, because some idioms are not recognized and thus missed-optimization.

> It’s not what we would like to do. But we’ll get the relief we need while LLVM and BPF core devs find an approach that works.

I think we need some "legalization" process for LLVM backend to convert these constraints in a "verifier-friendly" form. (Yes, we are converting optimizations back). But since IR is already canonicalized, I think generally this is the "correct" (but not yet very smart/efficient).

https://github.com/llvm/llvm-project/pull/97073


More information about the llvm-commits mailing list