-
Notifications
You must be signed in to change notification settings - Fork 12k
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
[CodeGen] Allow CodeGenPassBuilder
to add module pass after function pass
#77084
Conversation
d62a7bf
to
9755fa6
Compare
b66e697
to
f5e6c04
Compare
if constexpr (is_detected<is_module_pass_t, PassT>::value && | ||
!is_detected<is_function_pass_t, PassT>::value) { |
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.
Why are both conditions necessary? Can there really be a pass that is both a module and function pass?
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.
It seems ok to define two run methods with different ir unit in one pass, pass manager will pick the right one. Here is redundant, will remove it
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.
Updated.
f5e6c04
to
7ffc23e
Compare
7ffc23e
to
1d84f8f
Compare
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 with nits
addPass(createFunctionToLoopPassAdaptor( | ||
LoopStrengthReducePass(), /*UseMemorySSA*/ true, Opt.DebugPM)); | ||
addPass(createFunctionToLoopPassAdaptor(LoopStrengthReducePass(), | ||
/*UseMemorySSA*/ true)); |
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.
Something weird happened here with whitespace? Is GitHub showing tabs?
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.
At least in my local editor, it is whitespace.
"test", | ||
"-print-pipeline-passes", | ||
}; | ||
int argc = sizeof(argv) / sizeof(char *); |
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.
this can use std::size
"FinalizeISelPass,EarlyTailDuplicatePass,OptimizePHIsPass," | ||
"StackColoringPass,LocalStackSlotPass,DeadMachineInstructionElimPass," | ||
"EarlyMachineLICMPass,MachineCSEPass,MachineSinkingPass," | ||
"PeepholeOptimizerPass,DeadMachineInstructionElimPass," |
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.
At some point we should probably do something about codegen passes not using the same naming convention as IR passes
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, currently only PassT::name()
is available.
auto PassName = PIC.getPassNameForClassName(Name); | ||
return PassName.empty() ? Name : PassName; | ||
}); | ||
char ExpectedMIRPipeline[] = |
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.
const?
auto PassName = PIC.getPassNameForClassName(Name); | ||
return PassName.empty() ? Name : PassName; | ||
}); | ||
char ExpectedIRPipeline[] = |
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.
const?
1d84f8f
to
838bcce
Compare
Address the comments above. |
addPass(createFunctionToLoopPassAdaptor( | ||
LoopStrengthReducePass(), /*UseMemorySSA*/ true, Opt.DebugPM)); | ||
addPass(createFunctionToLoopPassAdaptor(LoopStrengthReducePass(), | ||
/*UseMemorySSA*/ true)); |
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.
UseMemorySSA= so clang-format recognizes it
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.
makes sense, some comments
"Only module pass and function pass are supported."); | ||
|
||
// Add Function Pass | ||
if constexpr (is_detected<is_function_pass_t, PassT>::value) |
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.
for consistency, add braces here when else block uses braces
return PassName.empty() ? Name : PassName; | ||
}); | ||
const char ExpectedMIRPipeline[] = | ||
"FinalizeISelPass,EarlyTailDuplicatePass,OptimizePHIsPass," |
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.
imo checking the exact pipeline should be a normal lit tests, having it as a unit test is annoying to update since it takes so long to compile unittests.
for now since we don't have the infra to do this from llc
this is ok, but add a TODO to move this to a normal lit test once we can do that
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.
to prevent having to update this as we keep making changes in this space, I'd just check that no-op-module,function(no-op-function,no-op-function,no-op-function),no-op-module
is a substring
} | ||
|
||
void SetUp() override { | ||
std::string TripleName = Triple::normalize(sys::getDefaultTargetTriple()); |
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.
isn't the pipeline going to be inconsistent depending on the default target triple?
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, it will depend on the specific target, but I noticed there is a BogusTargetMachine
in unittests/CodeGen/MFCommon.inc
, will use it 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.
Uh,CodeGenPassBuilder
needs MCAsmInfo
but BogusTargetMachine
doesn't provide it, but now we can ignore it and use default target machine because currently the pipeline provider is not the target machine.
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 be slightly safer to just pick a target machine and go with it, and disable the test if the target's not built
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 be slightly safer to just pick a target machine and go with it, and disable the test if the target's not built
Pick the default target machine and skip test when default target is not built now.
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 think arsenm meant choose a specific target like x86_64-linux-gnu
and bail if that target isn't available (I think you did this in a different patch's test)
|
||
static const char *argv[] = { | ||
"test", | ||
"-print-pipeline-passes", |
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.
oh man this is a huge hack, but I guess this goes along with the TODO I suggested below
"lower-constant-intrinsics,UnreachableBlockElimPass,consthoist," | ||
"ReplaceWithVeclib,partially-inline-libcalls,ee-instrument<post-inline>," | ||
"scalarize-masked-mem-intrin,ExpandReductionsPass,codegenprepare," | ||
"dwarf-eh-prepare),no-op-module,function(no-op-function,no-op-function," |
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.
no-op-function/module
are getting recognized just because we happen to have the same name for the NoOpFunction/ModulePass
in PassBuilder.cpp
, that's not very evident or nice. let's just move those in PassBuilder.cpp
to the header PassBuilder.h
so unittests can use them
…n pass In fact, there are several backends, e.g. AArch64, AMDGPU etc. add module pass after function pass, this patch removes this constraint. This patch also adds a simple unit test for `CodeGenPassBuilder`
838bcce
to
0237049
Compare
Address comments above. |
0237049
to
251e9bf
Compare
Smoke test looks good, will land this if no further comments. |
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.
lg after the one test comment is addressed
Looks like this might be breaking tests on Mac: http://45.33.8.238/macm1/76477/step_11.txt Please take a look. Does the failure make sense to you? |
I noticed that, fix pr is opened #77860. |
If build bots still report error, feel free to revert it. |
…n pass (llvm#77084) In fact, there are several backends, e.g. AArch64, AMDGPU etc. add module pass after function pass, this patch removes this constraint. This patch also adds a simple unit test for `CodeGenPassBuilder`.
In fact, there are several backends, e.g. AArch64, AMDGPU etc. add module pass after function pass, this patch removes this constraint. This patch also adds a simple unit test for
CodeGenPassBuilder
.