Commit Graph

3 Commits

Author SHA1 Message Date
Nikita Popov d452d5e2de [Bitcode] Fix constexpr autoupgrade for arrays and structs
While vectors use insertelement, structs and arrays should use
insertvalue.
2022-09-07 12:47:21 +02:00
Nikita Popov 0c40651f69 [Bitcode] Convert constexpr-to-instr.ll to use bitcode input (NFC)
We can't use an IR input once the relevant constant expressions
are no longer supported. Use a bitcode file instead, which will
be auto-upgraded (the whole point of this code...)
2022-09-07 12:29:32 +02:00
Nikita Popov 941c8e0ea5 [Bitcode] Support expanding constant expressions into instructions
This implements an autoupgrade from constant expressions to
instructions, which is needed for
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179.

The basic approach is that constant expressions (CST_CODE_CE_*
records) now initially only create a BitcodeConstant value that
holds opcode, flags and operands IDs. Then, when the value actually
gets used, it can be converted either into a constant expression
(if that expression type is still supported) or into a sequence of
instructions. As currently all expressions are still supported,
-expand-constant-exprs is added for testing purposes, to force
expansion.

PHI nodes require special handling, because the constant expression
needs to be evaluated on the incoming edge. We do this by putting
it into a temporary block and then wiring it up appropriately
afterwards (for non-critical edges, we could also move the
instructions into the predecessor).

This also removes the need for the forward referenced constants
machinery, as the BitcodeConstants only hold value IDs. At the
point where the value is actually materialized, no forward
references are needed anymore.

Differential Revision: https://reviews.llvm.org/D127729
2022-06-28 11:09:46 +02:00