Skip to content
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

[SPIR-V] Handle unreferenced globals at the main GlobalISel phases. #66

Merged

Conversation

zuban32
Copy link
Contributor

@zuban32 zuban32 commented Nov 4, 2021

Introduce 'unref_global' intrinsic for that purpose.
Empty modules (i.e. w/o any functions) are not processed,
think we should't do that at all, fixed the LIT.

Introduce 'unref_global' intrinsic for that purpose.
Empty modules (i.e. w/o any functions) are not processed,
think we should't do that at all, fixed the LIT.
@zuban32
Copy link
Contributor Author

zuban32 commented Nov 4, 2021

Doesn't affect passrate, still safer to merge after #63, #64, #65

@iliya-diyachkov
Copy link
Contributor

Empty modules (i.e. w/o any functions) are not processed

Probably yes, but as I see SPIRV documentation does not prohibit modules without functions. And spirv-val does not report a problem on such spv files. Are you sure that such modules (without entry points) are not used for example in CTS tests?

Another test with no functions: transcoding/global-constant-expression.ll

@@ -259,6 +259,12 @@ bool SPIRVPreTranslationLegalizer::runOnFunction(Function *Func,
InitInst->setArgOperand(1, Init);
InitConsts.insert(Init);
}
if ((!GV.hasInitializer() || isa<UndefValue>(GV.getInitializer())) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way why do you check that a GV does not have init value before creating call to spv_unref_global? I suppose referenced GV may be initialized (see transcoding/global-constant-expression.ll).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to double-check, but I suppose initialized unreferenced globals may be already handled by the 'global_init" intrinsic.

@zuban32
Copy link
Contributor Author

zuban32 commented Nov 5, 2021

Empty modules (i.e. w/o any functions) are not processed

Probably yes, but as I see SPIRV documentation does not prohibit modules without functions. And spirv-val does not report a problem on such spv files. Are you sure that such modules (without entry points) are not used for example in CTS tests?

Another test with no functions: transcoding/global-constant-expression.ll

This may be handled by creating a fake function w/o emitting it. I just don't like the idea of arbitrary code generation in various passes as the hoisting one in this case

@zuban32
Copy link
Contributor Author

zuban32 commented Nov 9, 2021

Oops, I wanted to postpone merging of this until we agreed on the approach, but it's ok, will do that in place.
@iliya-diyachkov pls don't merge my PRs silently, I keep track of them and will merge them myself :)

@iliya-diyachkov
Copy link
Contributor

Sorry for inconvenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants