diff options
author | Craig Topper <craig.topper@sifive.com> | 2024-07-17 13:06:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-17 13:06:58 -0700 |
commit | 495d3ea989d4e97ce77ee73d6b35b171a7346019 (patch) | |
tree | cb85cdd9ac5b36bceb0b3c93ca5b02645c2e231e /llvm/lib/CodeGen/MachineSink.cpp | |
parent | 8044a863518166db1a1e05df5c76e26d53dbbcb9 (diff) | |
download | llvm-495d3ea989d4e97ce77ee73d6b35b171a7346019.zip llvm-495d3ea989d4e97ce77ee73d6b35b171a7346019.tar.gz llvm-495d3ea989d4e97ce77ee73d6b35b171a7346019.tar.bz2 |
[MachineSink][RISCV] Only call isConstantPhysReg or isIgnorableUse for uses. (#99363)
The included test case contains X0 as a def register. X0 is considered a
constant register when it is a use. When its a def, it means to throw
away the result value.
If we treat it as a constant register here, we will execute the continue
and not assign `DefReg` to any register. This will cause a crash when
trying to get the register class for `DefReg` after the loop.
By only checking isConstantPhysReg for uses, we will reach the `return
false` a little further down and stop processing this instruction.
Diffstat (limited to 'llvm/lib/CodeGen/MachineSink.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineSink.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp index d782c8b..4b3ff57 100644 --- a/llvm/lib/CodeGen/MachineSink.cpp +++ b/llvm/lib/CodeGen/MachineSink.cpp @@ -417,7 +417,7 @@ bool MachineSinking::PerformSinkAndFold(MachineInstr &MI, continue; } - if (Reg.isPhysical() && + if (Reg.isPhysical() && MO.isUse() && (MRI->isConstantPhysReg(Reg) || TII->isIgnorableUse(MO))) continue; |