[PATCH] D125680: Correctly legalise stackmap operands

Edd Barrett via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 21 08:20:01 PDT 2022


vext01 added a comment.

I've just realised that no test covers the case where a `i128` constant is used as a stackmap live variable.

Before any attempt to legalise stackmap operands, a stackmap call would be directly translated to a target node and any constant `i128` operand becomes a `TargetConstant` (also of type `i128`).  LLVM would then crash if the value of the `i128` exceeds what can be expressed by an `i64` (see this bug <https://github.com/llvm/llvm-project/issues/55609>).

This change causes LLVM to try to legalise the constant i128, which comes with some other caveats. When legalising a constant i128, LLVM is going to want to expand the type into smaller chunks (in the case of a constant i128, two smaller i64s). This is problematic because the stackmap format has no way to express such an expansion -- it is assumed that a constant cannot be larger than 64-bits ([see `LargeConstant` here](https://llvm.org/docs/StackMaps.html#stack-map-format).

A similar issue will arise for non-constant i128s, which may be split across registers during legalisation. Again, the stackmap format has no way to express that: it is assumed that if something lives in registers, it cannot span more than a single register.

I don't want to change the stackmap format right now, so I'm going to have to try and find an imperfect solution in the interim. I hope that's OK.

Sorry this is taking so long.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125680/new/

https://reviews.llvm.org/D125680



More information about the llvm-commits mailing list