Skip to content

Commit 499e6c4

Browse files
aparshin-inteligcbot
authored andcommitted
prologue insertion pass should not update global state
It seems that there was some work left to be donerelated to SIMDCF and prologue insertion code. Replaced silent update of the global state with a warning and an option to emit fatal error.
1 parent 1ed87e2 commit 499e6c4

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXPrologEpilogInsertion.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,15 @@ static cl::opt<bool>
8282
ForceRetMemPassing("vc-stack-force-ret-mem",
8383
cl::desc("Pass all stackcall retval via stackmem"),
8484
cl::init(false));
85-
static cl::opt<bool> HandleMaskArgs("vc-stack-handle-mask-args",
85+
static cl::opt<bool>
86+
DefaultMaskArgsProcessingPolicy("vc-stack-handle-mask-args",
8687
cl::desc("Pass i1 arguments of stackcalls"),
8788
cl::init(true));
89+
static cl::opt<bool>
90+
AbortOnSIMDCF("vc-prologue-insertion-aborts-on-simdcf",
91+
cl::desc("fatal error is reported on simdcf detection by "
92+
"prologue insertion pass"),
93+
cl::init(false));
8894

8995
namespace {
9096

@@ -126,6 +132,7 @@ class GenXPrologEpilogInsertion
126132
unsigned ArgRegSize = 0;
127133
unsigned RetRegSize = 0;
128134

135+
bool HandleMaskArgs = true;
129136
bool UseGlobalMem = true;
130137

131138
void generateKernelProlog(Function &F);
@@ -249,6 +256,7 @@ bool GenXPrologEpilogInsertion::runOnFunction(Function &F) {
249256
NumCalls = CallsCalculator().getNumCalls(F);
250257
UseGlobalMem =
251258
F.getParent()->getModuleFlag(ModuleMD::UseSVMStack) != nullptr;
259+
HandleMaskArgs = DefaultMaskArgsProcessingPolicy;
252260
LLVM_DEBUG(dbgs() << "Visiting all calls in " << F.getName() << "\n");
253261
visit(F);
254262
LLVM_DEBUG(dbgs() << "Visiting finished\n");
@@ -273,13 +281,21 @@ void GenXPrologEpilogInsertion::visitCallInst(CallInst &I) {
273281
generateStackCall(&I);
274282
if (!IsIndirectCall) {
275283
auto IID = GenXIntrinsic::getAnyIntrinsicID(I.getCalledFunction());
276-
if (IID == GenXIntrinsic::genx_alloca)
284+
if (IID == GenXIntrinsic::genx_alloca) {
277285
generateAlloca(&I);
286+
return;
287+
}
278288
// TODO: conformance fails when we pass i1 args in presence of SIMDCF. Funny
279289
// thing is that ISPC doesn't use goto/join in its recursion tests so
280290
// they're fine (i.e. they're not affected by this option) unlike CM
281-
else if (IID == GenXIntrinsic::genx_simdcf_goto)
291+
if (IID == GenXIntrinsic::genx_simdcf_goto) {
282292
HandleMaskArgs = false;
293+
DiagnosticInfoPrologEpilogInsertion DiagErr(
294+
I.getFunction()->getName() + ": simdcf may not be properly supported",
295+
AbortOnSIMDCF ? DS_Error : DS_Warning);
296+
I.getContext().diagnose(DiagErr);
297+
return;
298+
}
283299
}
284300
}
285301

0 commit comments

Comments
 (0)