@@ -321,8 +321,7 @@ class SICacheControl {
321321 bool IsNonTemporal,
322322 bool IsLastUse = false ) const = 0;
323323
324- virtual bool finalizeStore (MachineBasicBlock::iterator &MI,
325- bool Atomic) const {
324+ virtual bool finalizeStore (MachineInstr &MI, bool Atomic) const {
326325 return false ;
327326 };
328327
@@ -603,8 +602,7 @@ class SIGfx12CacheControl : public SIGfx11CacheControl {
603602 bool IsVolatile, bool IsNonTemporal,
604603 bool IsLastUse) const override ;
605604
606- bool finalizeStore (MachineBasicBlock::iterator &MI,
607- bool Atomic) const override ;
605+ bool finalizeStore (MachineInstr &MI, bool Atomic) const override ;
608606
609607 bool insertRelease (MachineBasicBlock::iterator &MI, SIAtomicScope Scope,
610608 SIAtomicAddrSpace AddrSpace, bool IsCrossAddrSpaceOrdering,
@@ -2538,9 +2536,6 @@ bool SIGfx12CacheControl::enableVolatileAndOrNonTemporal(
25382536 if (IsVolatile) {
25392537 Changed |= setScope (MI, AMDGPU::CPol::SCOPE_SYS);
25402538
2541- if (Op == SIMemOp::STORE)
2542- Changed |= insertWaitsBeforeSystemScopeStore (MI);
2543-
25442539 // Ensure operation has completed at system scope to cause all volatile
25452540 // operations to be visible outside the program in a global order. Do not
25462541 // request cross address space as only the global address space can be
@@ -2553,9 +2548,8 @@ bool SIGfx12CacheControl::enableVolatileAndOrNonTemporal(
25532548 return Changed;
25542549}
25552550
2556- bool SIGfx12CacheControl::finalizeStore (MachineBasicBlock::iterator &MI,
2557- bool Atomic) const {
2558- MachineOperand *CPol = TII->getNamedOperand (*MI, OpName::cpol);
2551+ bool SIGfx12CacheControl::finalizeStore (MachineInstr &MI, bool Atomic) const {
2552+ MachineOperand *CPol = TII->getNamedOperand (MI, OpName::cpol);
25592553 if (!CPol)
25602554 return false ;
25612555
@@ -2570,7 +2564,7 @@ bool SIGfx12CacheControl::finalizeStore(MachineBasicBlock::iterator &MI,
25702564
25712565 // GFX12.5 only: Require SCOPE_SE on stores that may hit the scratch address
25722566 // space.
2573- if (TII->mayAccessScratchThroughFlat (* MI) && Scope == CPol::SCOPE_CU)
2567+ if (TII->mayAccessScratchThroughFlat (MI) && Scope == CPol::SCOPE_CU)
25742568 return setScope (MI, CPol::SCOPE_SE);
25752569
25762570 return false ;
@@ -2674,6 +2668,8 @@ bool SIMemoryLegalizer::expandStore(const SIMemOpInfo &MOI,
26742668 assert (!MI->mayLoad () && MI->mayStore ());
26752669
26762670 bool Changed = false ;
2671+ // FIXME: Necessary hack because iterator can lose track of the store.
2672+ MachineInstr &StoreMI = *MI;
26772673
26782674 if (MOI.isAtomic ()) {
26792675 if (MOI.getOrdering () == AtomicOrdering::Monotonic ||
@@ -2690,7 +2686,7 @@ bool SIMemoryLegalizer::expandStore(const SIMemOpInfo &MOI,
26902686 MOI.getIsCrossAddressSpaceOrdering (),
26912687 Position::BEFORE);
26922688
2693- Changed |= CC->finalizeStore (MI , /* Atomic=*/ true );
2689+ Changed |= CC->finalizeStore (StoreMI , /* Atomic=*/ true );
26942690 return Changed;
26952691 }
26962692
@@ -2703,7 +2699,7 @@ bool SIMemoryLegalizer::expandStore(const SIMemOpInfo &MOI,
27032699
27042700 // GFX12 specific, scope(desired coherence domain in cache hierarchy) is
27052701 // instruction field, do not confuse it with atomic scope.
2706- Changed |= CC->finalizeStore (MI , /* Atomic=*/ false );
2702+ Changed |= CC->finalizeStore (StoreMI , /* Atomic=*/ false );
27072703 return Changed;
27082704}
27092705
0 commit comments