[llvm] [LoongArch] Add `isSafeToMove` hook to prevent unsafe instruction motion (PR #163725)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 7 02:16:48 PST 2025


================
@@ -1993,6 +1994,10 @@ bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) {
       // Hard to reason about register liveness with predicated instruction.
       break;
 
+    if (!TII->isSafeToMove(*TIB, MBB, MF))
+      // Don't hoist the instruction if it isn't safe to move.
+      break;
+
----------------
OCHyams wrote:

I'm not best placed to review a target hook change - I'm not sure of best practice there. Your change here in BranchFolding.cpp STGM though. 

https://github.com/llvm/llvm-project/pull/163725


More information about the llvm-commits mailing list