Skip to content

Commit 86cae03

Browse files
author
Mikhail Gudim
committed
[CodeGen] Let RDA recompute live-ins.
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.
1 parent 7287816 commit 86cae03

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

llvm/lib/CodeGen/ReachingDefAnalysis.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/CodeGen/ReachingDefAnalysis.h"
10+
#include "llvm/ADT/PostOrderIterator.h"
1011
#include "llvm/ADT/SetOperations.h"
1112
#include "llvm/ADT/SmallSet.h"
13+
#include "llvm/CodeGen/LivePhysRegs.h"
1214
#include "llvm/CodeGen/LiveRegUnits.h"
1315
#include "llvm/CodeGen/MachineFrameInfo.h"
1416
#include "llvm/CodeGen/TargetInstrInfo.h"
@@ -287,6 +289,16 @@ void ReachingDefInfo::run(MachineFunction &mf) {
287289
TRI = STI.getRegisterInfo();
288290
TII = STI.getInstrInfo();
289291
LLVM_DEBUG(dbgs() << "********** REACHING DEFINITION ANALYSIS **********\n");
292+
293+
MachineFunctionProperties &Props = MF->getProperties();
294+
if (!Props.hasTracksLiveness()) {
295+
Props.setTracksLiveness();
296+
297+
SmallVector<MachineBasicBlock *> AllMBBsInPostOrder;
298+
for (MachineBasicBlock *MBB : post_order(MF))
299+
AllMBBsInPostOrder.push_back(MBB);
300+
fullyRecomputeLiveIns(AllMBBsInPostOrder);
301+
}
290302
init();
291303
traverse();
292304
}

llvm/test/CodeGen/RISCV/pr53662.mir

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@ body: |
1818
; CHECK-LABEL: name: b
1919
; CHECK: bb.0:
2020
; CHECK-NEXT: successors: %bb.1(0x80000000)
21+
; CHECK-NEXT: liveins: $x10
2122
; CHECK-NEXT: {{ $}}
2223
; CHECK-NEXT: PseudoBR %bb.1
2324
; CHECK-NEXT: {{ $}}
2425
; CHECK-NEXT: bb.1:
2526
; CHECK-NEXT: successors: %bb.2(0x80000000)
27+
; CHECK-NEXT: liveins: $x10
2628
; CHECK-NEXT: {{ $}}
2729
; CHECK-NEXT: DBG_VALUE $noreg
2830
; CHECK-NEXT: {{ $}}
2931
; CHECK-NEXT: bb.2:
32+
; CHECK-NEXT: liveins: $x10
33+
; CHECK-NEXT: {{ $}}
3034
; CHECK-NEXT: PseudoRET implicit killed $x10
3135
bb.0 :
3236
PseudoBR %bb.1

llvm/test/CodeGen/RISCV/rvv/fixed-vectors-emergency-slot.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ body: |
4747
4848
SD $x10, %stack.0, 0
4949
SD $x10, %stack.2, 0
50-
dead renamable $x15 = PseudoVSETIVLI 1, 72, implicit-def $vl, implicit-def $vtype
50+
renamable $x15 = PseudoVSETIVLI 1, 72, implicit-def $vl, implicit-def $vtype
5151
VS1R_V killed renamable $v25, %stack.1 :: (store (<vscale x 1 x s64>) into %stack.1, align 8)
5252
; This is here just to make all the eligible registers live at this point.
5353
; This way when we replace the frame index %stack.1 with its actual address

0 commit comments

Comments
 (0)