Skip to content

Commit 63cf197

Browse files
jaladreipsigcbot
authored andcommitted
Stack call related changes
Stack call related changes
1 parent ef8bef3 commit 63cf197

File tree

9 files changed

+37
-4
lines changed

9 files changed

+37
-4
lines changed

IGC/AdaptorCommon/RayTracing/RTArgs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ void ArgQuery::init(CallableShaderTypeMD FuncType, const FunctionMetaData &FMD)
3131
uint32_t Idx = 0;
3232
switch (FuncType) {
3333
case RayGen:
34+
case Prologue:
3435
case CallStackHandler:
3536
break;
3637
case Miss:

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11390,6 +11390,21 @@ void EmitPass::emitStackCall(llvm::CallInst *inst) {
1139011390

1139111391
bool isIndirectFCall = !F || F->hasFnAttribute("referenced-indirectly");
1139211392
bool isInvokeSIMDTarget = F && F->hasFnAttribute("invoke_simd_target");
11393+
11394+
if (inst->doesNotReturn()) {
11395+
11396+
IGC_ASSERT_MESSAGE(inst->getType()->isVoidTy(), "Call that does not return can't return a value");
11397+
IGC_ASSERT_MESSAGE(IGCLLVM::getNumArgOperands(inst) == 0, "Arguments for non-returning call are not implemented");
11398+
11399+
auto *funcAddr = GetSymbol(IGCLLVM::getCalledValue(inst));
11400+
funcAddr = TruncatePointer(funcAddr);
11401+
IGC_ASSERT_MESSAGE(funcAddr->IsUniform(), "Function address must be uniform for non-returning stack call");
11402+
m_encoder->IndirectStackCall(nullptr, funcAddr, 0, 0);
11403+
m_encoder->Push();
11404+
11405+
return;
11406+
}
11407+
1139311408
CVariable *ArgBlkVar = m_currShader->GetARGV();
1139411409
uint32_t offsetA = 0; // visa argument offset
1139511410
uint32_t offsetS = 0; // visa stack offset

IGC/Compiler/CISACodeGen/GenCodeGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ void GenXFunctionGroupAnalysis::setGroupAttributes() {
746746
} else if (!calledF || (calledF->isDeclaration() && calledF->hasFnAttribute("referenced-indirectly"))) {
747747
// This is the true indirect call case, where either the callee's address is taken, or it belongs
748748
// to an external module. We do not know the callgraph in this case.
749-
hasStackCall = true;
749+
hasStackCall = !call->doesNotReturn();
750750
FG->m_hasIndirectCall = true;
751751
FG->m_hasPartialCallGraph = true;
752752
} else if (calledF && calledF->hasFnAttribute("referenced-indirectly")) {

IGC/Compiler/CISACodeGen/Platform.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,8 @@ class CPlatform {
957957
}
958958
}
959959

960+
uint32_t getMinNumGRF() const { return supportsVRT() ? 32 : 128; }
961+
960962
uint32_t getInlineDataSize() const {
961963
if (!supportInlineData())
962964
return 0;

IGC/Compiler/CISACodeGen/RayTracingShaderLowering.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,14 @@ bool RayTracingShaderLowering::runOnModule(Module &M) {
212212
return EntryPreemptionVal;
213213
};
214214
const bool isFunc = !isEntryFunc(CGCtx->getMetaDataUtils(), &F);
215+
215216
if (ForcePreemptionDisable) {
216-
RTB.SetInsertPoint(&F.getEntryBlock().front());
217-
RTB.CreatePreemptionDisableIntrinsic();
217+
auto &rtInfo = CGCtx->getModuleMetaData()->FuncMD[&F].rtInfo;
218+
if (rtInfo.callableShaderType != Prologue) {
219+
// For raytracing shaders, disable preemption at entry
220+
RTB.SetInsertPoint(&F.getEntryBlock().front());
221+
RTB.CreatePreemptionDisableIntrinsic();
222+
}
218223
}
219224

220225
SmallVector<Instruction *, 8> DeadInsts;

IGC/Compiler/CodeGenPublic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@ struct SRayTracingShadersGroup {
524524
BindlessShaderVec m_CallableShaders;
525525
// Continuation shaders
526526
BindlessShaderVec m_Continuations;
527+
528+
std::optional<SBindlessProgram> prologueKernel;
527529
};
528530

529531
struct SRayTracingPipelineConfig {

IGC/common/MDFrameWork.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,10 @@ void IGC::serialize(const IGC::ModuleMetaData &moduleMD, Module *module) {
446446
}
447447

448448
bool IGC::isBindless(const IGC::FunctionMetaData &funcMD) {
449-
return funcMD.rtInfo.callableShaderType != RayGen || funcMD.rtInfo.isContinuation;
449+
if (funcMD.rtInfo.isContinuation)
450+
return true;
451+
452+
return funcMD.rtInfo.callableShaderType != RayGen && funcMD.rtInfo.callableShaderType != Prologue;
450453
}
451454

452455
bool IGC::isContinuation(const IGC::FunctionMetaData &funcMD) { return funcMD.rtInfo.isContinuation; }
@@ -455,6 +458,8 @@ bool IGC::isCallStackHandler(const IGC::FunctionMetaData &funcMD) {
455458
return funcMD.rtInfo.callableShaderType == IGC::CallStackHandler;
456459
}
457460

461+
bool IGC::isPrologue(const IGC::FunctionMetaData &funcMD) { return funcMD.rtInfo.callableShaderType == IGC::Prologue; }
462+
458463

459464
int IGC::extractAnnotatedNumThreads(const IGC::FunctionMetaData &funcMD) {
460465
static constexpr const char *searchedString = "num-thread-per-eu";

IGC/common/MDFrameWork.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@ enum class ShaderTypeMD
878878
bool isBindless(const IGC::FunctionMetaData &funcMD);
879879
bool isContinuation(const IGC::FunctionMetaData& funcMD);
880880
bool isCallStackHandler(const IGC::FunctionMetaData &funcMD);
881+
bool isPrologue(const IGC::FunctionMetaData &funcMD);
881882

882883

883884
// User annotations query functions

IGC/common/RaytracingShaderTypes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ enum CallableShaderTypeMD : uint32_t
2121
// by any RTUnit or BTD machinery. It is useful, though, to have all
2222
// shader types available for reference in this enum.
2323
RayGen,
24+
Prologue,
25+
NumberOfAllShaderTypes
2426
};
2527

0 commit comments

Comments
 (0)