-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SPIRV][OPT] Adding flag to run spirv structurizer #119301
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
Conversation
@llvm/pr-subscribers-backend-spir-v Author: None (joaosaffran) ChangesThis PR adds a new flag into OPT to run SPIRV structurizer, this is being added improving testing of such pass. This change is required to implement a test request that come #116331. Full diff: https://github.com/llvm/llvm-project/pull/119301.diff 4 Files Affected:
diff --git a/llvm/lib/Target/SPIRV/SPIRV.h b/llvm/lib/Target/SPIRV/SPIRV.h
index 384133e7b4bd18..81b57202644256 100644
--- a/llvm/lib/Target/SPIRV/SPIRV.h
+++ b/llvm/lib/Target/SPIRV/SPIRV.h
@@ -37,6 +37,7 @@ void initializeSPIRVModuleAnalysisPass(PassRegistry &);
void initializeSPIRVConvergenceRegionAnalysisWrapperPassPass(PassRegistry &);
void initializeSPIRVPreLegalizerPass(PassRegistry &);
void initializeSPIRVPostLegalizerPass(PassRegistry &);
+void initializeSPIRVStructurizerPass(PassRegistry &);
void initializeSPIRVEmitIntrinsicsPass(PassRegistry &);
void initializeSPIRVEmitNonSemanticDIPass(PassRegistry &);
} // namespace llvm
diff --git a/llvm/lib/Target/SPIRV/SPIRVStructurizer.cpp b/llvm/lib/Target/SPIRV/SPIRVStructurizer.cpp
index 13e05b67927518..641e6caa23f95a 100644
--- a/llvm/lib/Target/SPIRV/SPIRVStructurizer.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVStructurizer.cpp
@@ -1218,7 +1218,7 @@ INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(SPIRVConvergenceRegionAnalysisWrapperPass)
-INITIALIZE_PASS_END(SPIRVStructurizer, "structurize", "structurize SPIRV",
+INITIALIZE_PASS_END(SPIRVStructurizer, "structurizer", "structurize SPIRV",
false, false)
FunctionPass *llvm::createSPIRVStructurizerPass() {
diff --git a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
index d9d0d00cc71e41..744d4834b825c4 100644
--- a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
@@ -45,6 +45,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSPIRVTarget() {
initializeGlobalISel(PR);
initializeSPIRVModuleAnalysisPass(PR);
initializeSPIRVConvergenceRegionAnalysisWrapperPassPass(PR);
+ initializeSPIRVStructurizerPass(PR);
}
static std::string computeDataLayout(const Triple &TT) {
diff --git a/llvm/tools/opt/optdriver.cpp b/llvm/tools/opt/optdriver.cpp
index 8ef249e1708b95..d60000e8889a05 100644
--- a/llvm/tools/opt/optdriver.cpp
+++ b/llvm/tools/opt/optdriver.cpp
@@ -376,7 +376,7 @@ static bool shouldPinPassToLegacyPM(StringRef Pass) {
"expand-large-fp-convert",
"callbrprepare",
"scalarizer",
- };
+ "structurizer"};
for (const auto &P : PassNamePrefix)
if (Pass.starts_with(P))
return true;
|
@@ -1218,7 +1218,7 @@ INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) | |||
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass) | |||
INITIALIZE_PASS_DEPENDENCY(SPIRVConvergenceRegionAnalysisWrapperPass) | |||
|
|||
INITIALIZE_PASS_END(SPIRVStructurizer, "structurize", "structurize SPIRV", | |||
INITIALIZE_PASS_END(SPIRVStructurizer, "structurizer", "structurize SPIRV", |
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.
We should probably prefix the pass with spirv-
and connect it the way the DXIL-specific passes are. That reduces the surface area of exposing target-specific passes in code that isn't target-specific.
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.
LGTM for the idea, modulus the pass name fix
Thanks!
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.
LGTM. Thank you for adding this, we can extend this to other SPIRV passes in the future to enable better testing of the individual passes.
This PR adds a new flag into OPT to run SPIRV structurizer, this is being added improving testing of such pass.
This change is required to implement a test request that come #116331.