-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[SPIRV] Error for zero-length arrays if not a shader #169732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -883,10 +883,15 @@ SPIRVType *SPIRVGlobalRegistry::getOpTypeArray(uint32_t NumElems, | |
| .addUse(NumElementsVReg); | ||
| }); | ||
| } else { | ||
| assert(ST.isShader() && "Runtime arrays are not allowed in non-shader " | ||
| "SPIR-V modules."); | ||
| if (!ST.isShader()) | ||
| return nullptr; | ||
| if (!ST.isShader()) { | ||
| Function &Fn = MIRBuilder.getMF().getFunction(); | ||
| Fn.getContext().diagnose(DiagnosticInfoUnsupported( | ||
| Fn, | ||
| "Runtime arrays are not allowed in non-shader " | ||
| "SPIR-V modules", | ||
| MIRBuilder.getDebugLoc())); | ||
| return ElemType; | ||
|
||
| } | ||
| ArrayType = createOpType(MIRBuilder, [&](MachineIRBuilder &MIRBuilder) { | ||
| return MIRBuilder.buildInstr(SPIRV::OpTypeRuntimeArray) | ||
| .addDef(createTypeVReg(MIRBuilder)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does
diagnose(...)return and continues executing the backend code?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it properly errors out a bit after this. If we don't do this it still crashes with an error, with this there's just an error. If you know a better way to prevent a crash/assert but still throw an error let me know, I'd prefer that too.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would
llvm::report_fatal_errorbe better then? Reporting the error and immediately aborting seems to me like what you're asking for.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok if we use
llvm::reportFatalUsageErrorhere (llvm::report_fatal_erroris deprecated).We can revisit having proper diagnostics later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback, I reworked the error to use
llvm::reportFatalUsageErrorin my latest commit