This is an archive of the discontinued LLVM Phabricator instance.

[Scheduling] Enable AA in PostRA Machine scheduler
ClosedPublic

Authored by dmgreen on Nov 4 2019, 11:31 AM.

Details

Summary

This adds AA to Post-RA Machine Scheduling, allowing the pass more freedom when handling memory operations.

My understanding is that this was just never done, not that it is inherently incorrect to do so. The older PostRA List scheduler already makes use of AA, it's just that the MI PostRA Scheduler was never taught to use it.

Some PowerPC tests have changed, which I don't know a lot about but look like the same number of instructions! An AArch64 test is changed which looks OK.

Diff Detail

Event Timeline

dmgreen created this revision.Nov 4 2019, 11:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2019, 11:31 AM
hfinkel accepted this revision.Nov 4 2019, 12:52 PM

LGTM

If this is wrong (or buggy), then it will probably break self-hosting on PPC, so then we'll know.

This revision is now accepted and ready to land.Nov 4 2019, 12:52 PM

Thanks. I ran an AArch64 bootstrap with UseAA and PostRAScheduling forced on. That went fine at least!

This revision was automatically updated to reflect the committed changes.

Since this adds a dependency on the AAResultsWrapperPass, shouldn't we be informing the pass manager about it?

diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index 256628a179ae..950c87ea26f9 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -240,8 +240,11 @@ char PostMachineScheduler::ID = 0;
 
 char &llvm::PostMachineSchedulerID = PostMachineScheduler::ID;
 
-INITIALIZE_PASS(PostMachineScheduler, "postmisched",
-                "PostRA Machine Instruction Scheduler", false, false)
+INITIALIZE_PASS_BEGIN(PostMachineScheduler, "postmisched",
+                      "PostRA Machine Instruction Scheduler", false, false)
+INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
+INITIALIZE_PASS_END(PostMachineScheduler, "postmisched",
+                    "PostRA Machine Instruction Scheduler", false, false)
 
 PostMachineScheduler::PostMachineScheduler() : MachineSchedulerBase(ID) {
   initializePostMachineSchedulerPass(*PassRegistry::getPassRegistry());

Since this adds a dependency on the AAResultsWrapperPass, shouldn't we be informing the pass manager about it?

diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index 256628a179ae..950c87ea26f9 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -240,8 +240,11 @@ char PostMachineScheduler::ID = 0;
 
 char &llvm::PostMachineSchedulerID = PostMachineScheduler::ID;
 
-INITIALIZE_PASS(PostMachineScheduler, "postmisched",
-                "PostRA Machine Instruction Scheduler", false, false)
+INITIALIZE_PASS_BEGIN(PostMachineScheduler, "postmisched",
+                      "PostRA Machine Instruction Scheduler", false, false)
+INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
+INITIALIZE_PASS_END(PostMachineScheduler, "postmisched",
+                    "PostRA Machine Instruction Scheduler", false, false)
 
 PostMachineScheduler::PostMachineScheduler() : MachineSchedulerBase(ID) {
   initializePostMachineSchedulerPass(*PassRegistry::getPassRegistry());

https://reviews.llvm.org/D91561

Oh yeah. Sounds very sensible to me. Thanks!