================
@@ -9709,6 +9709,30 @@ unsigned SIInstrInfo::getLiveRangeSplitOpcode(Register 
SrcReg,
   return AMDGPU::COPY;
 }
 
+bool SIInstrInfo::canAddToBBProlog(const MachineInstr &MI) const {
+  uint16_t Opcode = MI.getOpcode();
+  // Check if it is SGPR spill or wwm-register spill Opcode.
+  if (isSGPRSpill(Opcode) || isWWMRegSpillOpcode(Opcode))
+    return true;
+
+  const MachineFunction *MF = MI.getMF();
+  const MachineRegisterInfo &MRI = MF->getRegInfo();
+  const SIMachineFunctionInfo *MFI = MF->getInfo<SIMachineFunctionInfo>();
+
+  // See if this is Liverange split instruction inserted for SGPR or
+  // wwm-register. The implicit def inserted for wwm-registers should also be
+  // included as they can appear at the bb begin.
+  bool IsLRSplitInst = MI.getFlag(MachineInstr::LRSplit);
----------------
cdevadas wrote:

> Instead of adding a flag, would it be enough to check that this is an SGPR 
> copy?

That won't help. It is important to note that this target hook is also invoked 
by other passes to identify the right insertion points, such as PHIElimination 
and MI Sink (called via `SkipPHIsAndLabels` & `SkipPHIsLabelsAndDebug`), which 
can lead to incorrect insertion points if all COPY instructions are included as 
part of BB Prolog (we have encountered some errors due to that. See this 
comment from the other PR 
https://github.com/llvm/llvm-project/pull/117543#issuecomment-3487026875). By 
adding an MI flag to LR_Split COPY instructions, we ensure that only the 
intended candidates are considered during RA while inserting spill and LR_split 
instructions.

https://github.com/llvm/llvm-project/pull/117544
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to