diff options
author | Stanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com> | 2019-01-21 19:11:26 +0000 |
---|---|---|
committer | Stanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com> | 2019-01-21 19:11:26 +0000 |
commit | f92ed6966eb898b1ab1587c5fb1bf059783977b0 (patch) | |
tree | 58583c47d14adf49943473acc1124cd52763f744 /llvm/lib/Target/AMDGPU/GCNHazardRecognizer.h | |
parent | 8441c467bf9b02638afc9fb3affce8eb1207e65d (diff) | |
download | bcm5719-llvm-f92ed6966eb898b1ab1587c5fb1bf059783977b0.tar.gz bcm5719-llvm-f92ed6966eb898b1ab1587c5fb1bf059783977b0.zip |
[AMDGPU] Fixed hazard recognizer to walk predecessors
Fixes two problems with GCNHazardRecognizer:
1. It only scans up to 5 instructions emitted earlier.
2. It does not take control flow into account. An earlier instruction
from the previous basic block is not necessarily a predecessor.
At the same time a real predecessor block is not scanned.
The patch provides a way to distinguish between scheduler and
hazard recognizer mode. It is OK to work with emitted instructions
in the scheduler because we do not really know what will be emitted
later and its order. However, when pass works as a hazard recognizer
the schedule is already finalized, and we have full access to the
instructions for the whole function, so we can properly traverse
predecessors and their instructions.
Differential Revision: https://reviews.llvm.org/D56923
llvm-svn: 351759
Diffstat (limited to 'llvm/lib/Target/AMDGPU/GCNHazardRecognizer.h')
-rw-r--r-- | llvm/lib/Target/AMDGPU/GCNHazardRecognizer.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.h b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.h index cc29d74a548..2a6a2deed2c 100644 --- a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.h +++ b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.h @@ -30,6 +30,13 @@ class SIRegisterInfo; class GCNSubtarget; class GCNHazardRecognizer final : public ScheduleHazardRecognizer { +public: + typedef function_ref<bool(MachineInstr *)> IsHazardFn; + +private: + // Distinguish if we are called from scheduler or hazard recognizer + bool IsHazardRecognizerMode; + // This variable stores the instruction that has been emitted this cycle. It // will be added to EmittedInstrs, when AdvanceCycle() or RecedeCycle() is // called. @@ -53,11 +60,9 @@ class GCNHazardRecognizer final : public ScheduleHazardRecognizer { void addClauseInst(const MachineInstr &MI); - int getWaitStatesSince(function_ref<bool(MachineInstr *)> IsHazard); - int getWaitStatesSinceDef(unsigned Reg, - function_ref<bool(MachineInstr *)> IsHazardDef = - [](MachineInstr *) { return true; }); - int getWaitStatesSinceSetReg(function_ref<bool(MachineInstr *)> IsHazard); + int getWaitStatesSince(IsHazardFn IsHazard, int Limit); + int getWaitStatesSinceDef(unsigned Reg, IsHazardFn IsHazardDef, int Limit); + int getWaitStatesSinceSetReg(IsHazardFn IsHazard, int Limit); int checkSoftClauseHazards(MachineInstr *SMEM); int checkSMRDHazards(MachineInstr *SMRD); @@ -84,6 +89,7 @@ public: void EmitNoop() override; unsigned PreEmitNoops(SUnit *SU) override; unsigned PreEmitNoops(MachineInstr *) override; + unsigned PreEmitNoopsCommon(MachineInstr *); void AdvanceCycle() override; void RecedeCycle() override; }; |