-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[CodeGen] Let RDA recompute live-ins. #166773
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
base: main
Are you sure you want to change the base?
Conversation
|
@llvm/pr-subscribers-backend-risc-v Author: Mikhail Gudim (mgudim) ChangesWe plan to use Full diff: https://github.com/llvm/llvm-project/pull/166773.diff 3 Files Affected:
diff --git a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
index 40a89078bcf59..b4b7e0b64ab4e 100644
--- a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
+++ b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
@@ -7,8 +7,10 @@
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/ReachingDefAnalysis.h"
+#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/SetOperations.h"
#include "llvm/ADT/SmallSet.h"
+#include "llvm/CodeGen/LivePhysRegs.h"
#include "llvm/CodeGen/LiveRegUnits.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
@@ -287,6 +289,16 @@ void ReachingDefInfo::run(MachineFunction &mf) {
TRI = STI.getRegisterInfo();
TII = STI.getInstrInfo();
LLVM_DEBUG(dbgs() << "********** REACHING DEFINITION ANALYSIS **********\n");
+
+ MachineFunctionProperties &Props = MF->getProperties();
+ if (!Props.hasTracksLiveness()) {
+ Props.setTracksLiveness();
+
+ SmallVector<MachineBasicBlock *> AllMBBsInPostOrder;
+ for (MachineBasicBlock *MBB : post_order(MF))
+ AllMBBsInPostOrder.push_back(MBB);
+ fullyRecomputeLiveIns(AllMBBsInPostOrder);
+ }
init();
traverse();
}
diff --git a/llvm/test/CodeGen/RISCV/pr53662.mir b/llvm/test/CodeGen/RISCV/pr53662.mir
index dccad40368111..834bcbc1cf82c 100644
--- a/llvm/test/CodeGen/RISCV/pr53662.mir
+++ b/llvm/test/CodeGen/RISCV/pr53662.mir
@@ -18,15 +18,19 @@ body: |
; CHECK-LABEL: name: b
; CHECK: bb.0:
; CHECK-NEXT: successors: %bb.1(0x80000000)
+ ; CHECK-NEXT: liveins: $x10
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: PseudoBR %bb.1
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.1:
; CHECK-NEXT: successors: %bb.2(0x80000000)
+ ; CHECK-NEXT: liveins: $x10
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: DBG_VALUE $noreg
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.2:
+ ; CHECK-NEXT: liveins: $x10
+ ; CHECK-NEXT: {{ $}}
; CHECK-NEXT: PseudoRET implicit killed $x10
bb.0 :
PseudoBR %bb.1
diff --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-emergency-slot.mir b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-emergency-slot.mir
index c728fcb8d8b0d..44f60a43a2790 100644
--- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-emergency-slot.mir
+++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-emergency-slot.mir
@@ -47,7 +47,7 @@ body: |
SD $x10, %stack.0, 0
SD $x10, %stack.2, 0
- dead renamable $x15 = PseudoVSETIVLI 1, 72, implicit-def $vl, implicit-def $vtype
+ renamable $x15 = PseudoVSETIVLI 1, 72, implicit-def $vl, implicit-def $vtype
VS1R_V killed renamable $v25, %stack.1 :: (store (<vscale x 1 x s64>) into %stack.1, align 8)
; This is here just to make all the eligible registers live at this point.
; This way when we replace the frame index %stack.1 with its actual address
|
| SD $x10, %stack.0, 0 | ||
| SD $x10, %stack.2, 0 | ||
| dead renamable $x15 = PseudoVSETIVLI 1, 72, implicit-def $vl, implicit-def $vtype | ||
| renamable $x15 = PseudoVSETIVLI 1, 72, implicit-def $vl, implicit-def $vtype |
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 removed dead here because it was wrong - $x15 is used later.
|
I am not sure that this is a proper way to solve the problem. My concern is that Please suggest other approaches if you have any ideas! |
86cae03 to
92ebb42
Compare
We plan to use `ReachingDefinitionsAnalysis` in `PrologEpilogInsertion`. In some tests this will be a problem because `ReachingDefinitionAnalysis` will have to run on a function that does not have live-in info. This PR lets `ReachingDefinitionsAnalysis` recompute live-ins.
92ebb42 to
2e65450
Compare
|
IIRC, RDA doesn't track function live-ins particularly well. I've worked around this in the past, but this issue would give me pause for using RDA in PEI, before the issue is resolved. |
We plan to use
ReachingDefinitionsAnalysisinPrologEpilogInsertion. In some tests this will be a problem becauseReachingDefinitionAnalysiswill have to run on a function that does not have live-in info. This PR letsReachingDefinitionsAnalysisrecompute live-ins.