diff options
author | Sergei Barannikov <barannikov88@gmail.com> | 2024-01-13 11:17:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-13 11:17:41 +0300 |
commit | 8e8c954a173e0e814de1207513f357e99dff2e85 (patch) | |
tree | 44bd95e7bf1ca839689fce1520e13bce2a84e59a /llvm/lib/Support/CommandLine.cpp | |
parent | 8e8bbbd48ee23764cc6030fd259dde6a1107c00c (diff) | |
download | llvm-8e8c954a173e0e814de1207513f357e99dff2e85.zip llvm-8e8c954a173e0e814de1207513f357e99dff2e85.tar.gz llvm-8e8c954a173e0e814de1207513f357e99dff2e85.tar.bz2 |
[GISel] Erase the root instruction after emitting all its potential uses (#77494)
This tries to fix a bug by resolving a few FIXMEs. The bug is that
`EraseInstAction` is emitted after emitting the _first_ `BuildMIAction`,
which is too early because the erased instruction may still be used by
subsequent `BuildMIAction`s (in particular, by `CopyRenderer`).
An example of the bug (from `match-table-operand-types.td`):
```
def InstTest0 : GICombineRule<
(defs root:$a),
(match (G_MUL i32:$x, i32:$b, i32:$c),
(G_MUL $a, i32:$b, i32:$x)),
(apply (G_ADD i64:$tmp, $b, i32:$c),
(G_ADD i8:$a, $b, i64:$tmp))>;
GIR_EraseFromParent, /*InsnID*/0,
GIR_BuildMI, /*InsnID*/1, /*Opcode*/GIMT_Encode2(TargetOpcode::G_ADD),
GIR_Copy, /*NewInsnID*/1, /*OldInsnID*/0, /*OpIdx*/0, // a
GIR_Copy, /*NewInsnID*/1, /*OldInsnID*/0, /*OpIdx*/1, // b
GIR_AddSimpleTempRegister, /*InsnID*/1, /*TempRegID*/0,
```
Here, the root instruction is destroyed before copying its operands ('a'
and 'b') to the new instruction.
The solution is to emit `EraseInstAction` for the root instruction as
the last action in the emission pipeline.
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
0 files changed, 0 insertions, 0 deletions