aboutsummaryrefslogtreecommitdiff
path: root/backend/unittests/Target/RISCVSSAExitTest.cpp
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-09 00:27:27 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-09 00:27:27 +0800
commit6c7cecc81a4c7e06e26027e21edd2cfd95a37a0b (patch)
tree2e39843b9de9c6534c67a768d923788af6292451 /backend/unittests/Target/RISCVSSAExitTest.cpp
parent77884c967d1cbc48afcbaef7e5a35adcb3c5da1b (diff)
downloadrcc-project-6c7cecc81a4c7e06e26027e21edd2cfd95a37a0b.tar.gz
rcc-project-6c7cecc81a4c7e06e26027e21edd2cfd95a37a0b.tar.xz
[CodeGen] Implement machine liveness analysis
Diffstat (limited to 'backend/unittests/Target/RISCVSSAExitTest.cpp')
-rw-r--r--backend/unittests/Target/RISCVSSAExitTest.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/backend/unittests/Target/RISCVSSAExitTest.cpp b/backend/unittests/Target/RISCVSSAExitTest.cpp
index 1440855..8e1f5a2 100644
--- a/backend/unittests/Target/RISCVSSAExitTest.cpp
+++ b/backend/unittests/Target/RISCVSSAExitTest.cpp
@@ -6,6 +6,7 @@
#include "rcc/CodeGen/MachineFunction.h"
#include "rcc/CodeGen/MachineIRBuilder.h"
#include "rcc/CodeGen/MachineInstr.h"
+#include "rcc/CodeGen/MachineLiveness.h"
#include "rcc/CodeGen/MachineOperand.h"
#include "rcc/CodeGen/MachinePass.h"
#include "rcc/CodeGen/MachineSSAExit.h"
@@ -167,13 +168,18 @@ buildPhi(rcc::MachineFunction &Function, const rcc::TargetDescription &Target,
return Result;
}
-void setSelectedSSAProperties(rcc::MachineFunction &Function) {
+[[nodiscard]] rcc::Expected<void> setSelectedSSAProperties(rcc::MachineFunction &Function,
+ const rcc::TargetDescription &Target) {
+ auto Rebuilt = rcc::rebuildMachineLiveness(Function, Target);
+ if (!Rebuilt)
+ return std::unexpected(Rebuilt.error());
for (rcc::MachineFunctionProperty Property :
{rcc::MachineFunctionProperty::IsSSA, rcc::MachineFunctionProperty::TracksLiveness,
rcc::MachineFunctionProperty::Legalized, rcc::MachineFunctionProperty::RegBankSelected,
rcc::MachineFunctionProperty::Selected}) {
Function.properties().set(Property);
}
+ return {};
}
void testBehaviorAndCopyLegality(TestContext &Context, const rcc::TargetDescription &Target) {
@@ -286,7 +292,10 @@ void testRV64GCCriticalEdge(TestContext &Context, const rcc::TargetDescription &
std::pair<rcc::Register, rcc::MachineBasicBlock *>{*OtherValue, *Other}};
Context.expect(buildPhi(**Function, Target, **Merge, *Destination, Incoming).has_value(),
"RV64GC critical-edge PHI must be built");
- setSelectedSSAProperties(**Function);
+ auto InitialLiveness = setSelectedSSAProperties(**Function, Target);
+ Context.expect(InitialLiveness.has_value(), "RV64GC PHI liveness rebuild must succeed");
+ if (!InitialLiveness)
+ return;
rcc::MachinePassManager Pipeline;
Context.expect(Pipeline.addPass(std::make_unique<rcc::PHIEliminationPass>(rcc::riscv::ssaInfo()))