InstCombine needs to be performed after simplifycfg and sroa, otherwise it may make bad optimization decisions.
Details
Diff Detail
Event Timeline
It may be helpful to provide more background here, especially whether this change affect samplefdo only or it may affect non-fdo mode too. We may need such information to justify the change.
lib/CodeGen/BackendUtil.cpp | ||
---|---|---|
185 | This way sroa and cfgsimplify passes will be added before every Instcombine pass. Is it necessary? or it is only needed to add cfgsimplify and sroa for the first instcombine pass before sample fdo annotate? |
Change the function name to assert that this function should only be called for sample profiler.
add comment to the function to explain why these passes are needed before sample profile pass.
lib/CodeGen/BackendUtil.cpp | ||
---|---|---|
182–184 | This is becoming much more than adding instcombine. Perhaps something like addCleanupPassesForSampleProfiler? | |
185 | s/is needed/are needed/ What is this necessary preparation that they're needed for? In these descriptions, brevity is our enemy :) If you could write down more context here, that would be great. Thanks! | |
test/CodeGen/pgo-sample.c | ||
1 | So, for this test case, it's fine that we are showing that the passes are being run. But, is there a test case where we can test that the cleanup passes do something actually useful? Perhaps an IL test that shows the transformations you're after. |
This is becoming much more than adding instcombine. Perhaps something like addCleanupPassesForSampleProfiler?