[llvm] [AMDGPU] Mitigate GFX12 VALU read SGPR hazard (PR #100067)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 23 05:10:52 PDT 2024
================
@@ -2759,6 +2762,36 @@ bool GCNHazardRecognizer::ShouldPreferAnother(SUnit *SU) {
return false;
}
+// Adjust global offsets for instructions bundled with S_GETPC_B64 after
+// insertion of a new instruction.
+static void updateGetPCBundle(MachineInstr *NewMI) {
+ if (!NewMI->isBundled())
+ return;
+
+ // Find start of bundle.
+ auto I = NewMI->getIterator();
+ while (I->isBundledWithPred())
+ I--;
+ if (I->isBundle())
+ I++;
+
+ // Bail if this is not an S_GETPC bundle.
+ if (I->getOpcode() != AMDGPU::S_GETPC_B64)
+ return;
+
+ // Update offsets of any references in the bundle.
+ const unsigned NewBytes = NewMI->getDesc().getSize();
+ auto NextMI = std::next(NewMI->getIterator());
+ auto End = NewMI->getParent()->end();
+ while (NextMI != End && NextMI->isBundledWithPred()) {
+ for (auto &Operand : NextMI->operands()) {
+ if (Operand.isGlobal())
+ Operand.setOffset(Operand.getOffset() + NewBytes);
+ }
+ NextMI++;
+ }
----------------
arsenm wrote:
This whole function is concerning. We really don't want to be depending on exact byte offsets here. You cannot trivially query the MCInstrDesc to get the instruction size, and getInstSizeInBytes will give conservative results. Why do you need to consider the instruction sizes here in the first place, for global references? A global reference wouldn't be PC relative?
https://github.com/llvm/llvm-project/pull/100067
More information about the llvm-commits
mailing list