diff options
| author | Junjie Gu <junjie.gu@intel.com> | 2025-11-09 00:18:43 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-09 00:18:43 -0800 |
| commit | 93d445cba39f4dd3dcda4fa1433eca825cf8fc09 (patch) | |
| tree | 6949a51e1d6ceb2eeabd1d803d1a9dbffdf7c9be | |
| parent | 8cc49fb99a4798f67b6b70fabfd584095d022e92 (diff) | |
| download | llvm-93d445cba39f4dd3dcda4fa1433eca825cf8fc09.tar.gz llvm-93d445cba39f4dd3dcda4fa1433eca825cf8fc09.tar.bz2 llvm-93d445cba39f4dd3dcda4fa1433eca825cf8fc09.zip | |
[PostRASink] Add target hook shouldPostRASink (#167182)
| -rw-r--r-- | llvm/include/llvm/CodeGen/TargetInstrInfo.h | 3 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/MachineSink.cpp | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/llvm/include/llvm/CodeGen/TargetInstrInfo.h b/llvm/include/llvm/CodeGen/TargetInstrInfo.h index 2dcedfb40f3e..7010cffe23a1 100644 --- a/llvm/include/llvm/CodeGen/TargetInstrInfo.h +++ b/llvm/include/llvm/CodeGen/TargetInstrInfo.h @@ -436,7 +436,10 @@ public: /// MachineSink determines on its own whether the instruction is safe to sink; /// this gives the target a hook to override the default behavior with regards /// to which instructions should be sunk. + /// + /// shouldPostRASink() is used by PostRAMachineSink. virtual bool shouldSink(const MachineInstr &MI) const { return true; } + virtual bool shouldPostRASink(const MachineInstr &MI) const { return true; } /// Return false if the instruction should not be hoisted by MachineLICM. /// diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp index cdcb29d92bfe..94ed82eee9b8 100644 --- a/llvm/lib/CodeGen/MachineSink.cpp +++ b/llvm/lib/CodeGen/MachineSink.cpp @@ -2287,6 +2287,10 @@ bool PostRAMachineSinkingImpl::tryToSinkCopy(MachineBasicBlock &CurBB, continue; } + // Don't postRASink instructions that the target prefers not to sink. + if (!TII->shouldPostRASink(MI)) + continue; + if (MI.isDebugOrPseudoInstr()) continue; |
