Commit fa860a04 authored by Chen, Weiyu's avatar Chen, Weiyu

Disable preemption when stack call is used

Change-Id: Idb367b0ac031bf5f6734e8ac121eb842f5fb08da
parent 1e1e4a23
......@@ -3381,7 +3381,7 @@ void CEncoder::BeginStackFunction(llvm::Function *F)
V(vKernel->AppendVISACFLabelInst(visaLabel));
}
void CEncoder::InitEncoder( bool canAbortOnSpill )
void CEncoder::InitEncoder( bool canAbortOnSpill, bool hasStackCall )
{
m_aliasesMap.clear();
m_encoderState.m_SubSpanDestination = false;
......@@ -3591,7 +3591,7 @@ void CEncoder::InitEncoder( bool canAbortOnSpill )
}
if ((context->type == ShaderType::OPENCL_SHADER || context->type == ShaderType::COMPUTE_SHADER) &&
VISAPlatform >= GENX_SKL && IGC_IS_FLAG_ENABLED(EnablePreemption))
VISAPlatform >= GENX_SKL && IGC_IS_FLAG_ENABLED(EnablePreemption) && !hasStackCall)
{
vbuilder->SetOption(vISA_enablePreemption, true);
}
......
......@@ -128,7 +128,7 @@ struct SEncoderState
class CEncoder
{
public:
void InitEncoder( bool canAbortOnSpill );
void InitEncoder( bool canAbortOnSpill, bool hasStackCall);
SEncoderState CopyEncoderState();
void SetEncoderState(SEncoderState &newState);
......
......@@ -387,12 +387,13 @@ bool EmitPass::runOnFunction(llvm::Function &F)
{
return false;
}
bool hasStackCall = m_FGA && m_FGA->getGroup(&F)->hasStackCall();
// call builder after pre-analysis pass where scratchspace offset to VISA is calculated
m_encoder->InitEncoder(m_canAbortOnSpill);
m_encoder->InitEncoder(m_canAbortOnSpill, hasStackCall);
m_roundingMode = m_encoder->getEncoderRoundingMode(
static_cast<Float_RoundingMode>(ctx->getModuleMetaData()->compOpt.FloatRoundingMode));
m_currShader->PreCompile();
if (m_FGA && m_FGA->getGroup(&F)->hasStackCall())
if (hasStackCall)
{
m_currShader->InitKernelStack(ptr64bits);
}
......
......@@ -1714,11 +1714,7 @@ void Interference::addCalleeSaveBias(BitSet& live)
{
for (unsigned i = 0; i < maxId; i++)
{
if (live.isSet(i) &&
!lrs[i]->getDcl()->getHasFileScope() &&
!(kernel.fg.builder->getOption(vISA_enablePreemption) &&
lrs[i]->getDcl() == kernel.fg.builder->getBuiltinR0() &&
kernel.fg.getIsStackCallFunc()))
if (live.isSet(i) && !lrs[i]->getDcl()->getHasFileScope())
{
lrs[i]->setCallerSaveBias(false);
lrs[i]->setCalleeSaveBias(true);
......@@ -5071,14 +5067,6 @@ void GraphColor::createLiveRanges(unsigned reserveSpillSize)
{
lrs[var->getId()]->allocForbiddenCallerSave(mem, &builder.kernel);
}
else if (builder.getOption(vISA_enablePreemption) &&
varDcl == builder.getBuiltinR0() &&
builder.kernel.fg.getIsStackCallFunc())
{
lrs[var->getId()]->setCallerSaveBias(true);
lrs[var->getId()]->setCalleeSaveBias(false);
lrs[var->getId()]->allocForbiddenCallerSave(mem, &builder.kernel);
}
}
}
......@@ -6497,7 +6485,7 @@ void GraphColor::saveSubRegs(
G4_DstRegRegion* dst = builder.createDstRegRegion(Direct, scratchRegDcl->getRegVar(), 0, 0, 1, Type_UD);
RegionDesc* rDesc = builder.rgnpool.createRegion(8, 8, 1);
G4_Operand* src = builder.createSrcRegRegion(
Mod_src_undef, Direct, builder.getBuiltinR0()->getRegVar(), 0, 0, rDesc, Type_UD);
Mod_src_undef, Direct, builder.getRealR0()->getRegVar(), 0, 0, rDesc, Type_UD);
G4_INST* hdrInitInst = builder.createInternalInst(NULL, G4_mov, NULL, false, 8, dst, src,
NULL, InstOpt_WriteEnable);
bb->insert(insertIt, hdrInitInst);
......@@ -6582,7 +6570,7 @@ void GraphColor::saveRegs(
// sends (8) null<1>:ud r126.0 r1.0 ...
uint8_t execSize = (owordSize > 2) ? 16 : 8;
auto dstRgn = builder.createDstRegRegion(Direct, scratchRegDcl->getRegVar(), 0, 0, 1, Type_UD);
auto srcRgn = builder.createSrcRegRegion(Mod_src_undef, Direct, builder.getBuiltinR0()->getRegVar(), 0,
auto srcRgn = builder.createSrcRegRegion(Mod_src_undef, Direct, builder.getRealR0()->getRegVar(), 0,
0, builder.rgnpool.createRegion(8, 8, 1), Type_UD);
G4_INST* mov = builder.createInternalInst(NULL, G4_mov, NULL, false, 8, dstRgn, srcRgn, NULL, InstOpt_WriteEnable);
......@@ -6705,7 +6693,7 @@ void GraphColor::restoreSubRegs(
G4_DstRegRegion* dst = builder.createDstRegRegion(Direct, scratchRegDcl->getRegVar(), 1, 0, 1, Type_UD);
RegionDesc* rDesc = builder.rgnpool.createRegion(8, 8, 1);
G4_Operand* src = builder.createSrcRegRegion(
Mod_src_undef, Direct, builder.getBuiltinR0()->getRegVar(), 0, 0, rDesc, Type_UD);
Mod_src_undef, Direct, builder.getRealR0()->getRegVar(), 0, 0, rDesc, Type_UD);
G4_INST* hdrInitInst = builder.createInternalInst(NULL, G4_mov, NULL, false, 8,
dst, src, NULL, InstOpt_WriteEnable);
bb->insert(insertIt, hdrInitInst);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment