LLVM  13.0.0git
Macros | Functions | Variables
SIInsertWaitcnts.cpp File Reference
#include "AMDGPU.h"
#include "GCNSubtarget.h"
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
#include "SIMachineFunctionInfo.h"
#include "Utils/AMDGPUBaseInfo.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/CodeGen/MachinePostDominators.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/DebugCounter.h"
#include "llvm/Support/TargetParser.h"
Include dependency graph for SIInsertWaitcnts.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "si-insert-waitcnts"
 
#define CNT_MASK(t)   (1u << (t))
 

Functions

 DEBUG_COUNTER (ForceExpCounter, DEBUG_TYPE"-forceexp", "Force emit s_waitcnt expcnt(0) instrs")
 
 DEBUG_COUNTER (ForceLgkmCounter, DEBUG_TYPE"-forcelgkm", "Force emit s_waitcnt lgkmcnt(0) instrs")
 
 DEBUG_COUNTER (ForceVMCounter, DEBUG_TYPE"-forcevm", "Force emit s_waitcnt vmcnt(0) instrs")
 
 INITIALIZE_PASS_BEGIN (SIInsertWaitcnts, DEBUG_TYPE, "SI Insert Waitcnts", false, false) INITIALIZE_PASS_END(SIInsertWaitcnts
 
static bool readsVCCZ (const MachineInstr &MI)
 
static bool callWaitsOnFunctionEntry (const MachineInstr &MI)
 
static bool callWaitsOnFunctionReturn (const MachineInstr &MI)
 

Variables

static cl::opt< bool > ForceEmitZeroFlag ("amdgpu-waitcnt-forcezero", cl::desc("Force all waitcnt instrs to be emitted as s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)"), cl::init(false), cl::Hidden)
 
 DEBUG_TYPE
 
SI Insert Waitcnts
 
SI Insert false
 

Detailed Description

Insert wait instructions for memory reads and writes.

Memory reads and writes are issued asynchronously, so we need to insert S_WAITCNT instructions when we want to access any of their results or overwrite any register that's used asynchronously.

TODO: This pass currently keeps one timeline per hardware counter. A more finely-grained approach that keeps one timeline per event type could sometimes get away with generating weaker s_waitcnt instructions. For example, when both SMEM and LDS are in flight and we need to wait for the i-th-last LDS instruction, then an lgkmcnt(i) is actually sufficient, but the pass will currently generate a conservative lgkmcnt(0) because multiple event types are in flight.

Definition in file SIInsertWaitcnts.cpp.

Macro Definition Documentation

◆ CNT_MASK

#define CNT_MASK (   t)    (1u << (t))

Definition at line 78 of file SIInsertWaitcnts.cpp.

◆ DEBUG_TYPE

#define DEBUG_TYPE   "si-insert-waitcnts"

Definition at line 39 of file SIInsertWaitcnts.cpp.

Function Documentation

◆ callWaitsOnFunctionEntry()

static bool callWaitsOnFunctionEntry ( const MachineInstr MI)
static
Returns
true if the callee inserts an s_waitcnt 0 on function entry.

Definition at line 914 of file SIInsertWaitcnts.cpp.

◆ callWaitsOnFunctionReturn()

static bool callWaitsOnFunctionReturn ( const MachineInstr MI)
static
Returns
true if the callee is expected to wait for any outstanding waits before returning.

Definition at line 924 of file SIInsertWaitcnts.cpp.

◆ DEBUG_COUNTER() [1/3]

DEBUG_COUNTER ( ForceExpCounter  ,
DEBUG_TYPE"-forceexp"  ,
"Force emit s_waitcnt expcnt(0) instrs"   
)

◆ DEBUG_COUNTER() [2/3]

DEBUG_COUNTER ( ForceLgkmCounter  ,
DEBUG_TYPE"-forcelgkm"  ,
"Force emit s_waitcnt lgkmcnt(0) instrs"   
)

◆ DEBUG_COUNTER() [3/3]

DEBUG_COUNTER ( ForceVMCounter  ,
DEBUG_TYPE"-forcevm"  ,
"Force emit s_waitcnt vmcnt(0) instrs"   
)

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( SIInsertWaitcnts  ,
DEBUG_TYPE  ,
"SI Insert Waitcnts ,
false  ,
false   
)

◆ readsVCCZ()

static bool readsVCCZ ( const MachineInstr MI)
static

Definition at line 907 of file SIInsertWaitcnts.cpp.

References MI.

Variable Documentation

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 795 of file SIInsertWaitcnts.cpp.

◆ false

SI Insert false

Definition at line 795 of file SIInsertWaitcnts.cpp.

◆ ForceEmitZeroFlag

cl::opt<bool> ForceEmitZeroFlag("amdgpu-waitcnt-forcezero", cl::desc("Force all waitcnt instrs to be emitted as s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)"), cl::init(false), cl::Hidden)
static

◆ Waitcnts

SI Insert Waitcnts

Definition at line 795 of file SIInsertWaitcnts.cpp.