aboutsummaryrefslogtreecommitdiff
path: root/backend/unittests/CodeGen
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-12 02:30:19 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-12 02:30:19 +0800
commit0e73b1821cacb453c307cc1b9f35e989321b8e42 (patch)
treed9c59378c840bc7b49bcc9458fb0fc3a04aa28e2 /backend/unittests/CodeGen
parent5ee4740bc864a8aaddb50e8e7a43cb5a18df0fcf (diff)
downloadrcc-project-0e73b1821cacb453c307cc1b9f35e989321b8e42.tar.gz
rcc-project-0e73b1821cacb453c307cc1b9f35e989321b8e42.tar.xz
[CodeGen] Preserve variable-sized stack object offsets
Diffstat (limited to 'backend/unittests/CodeGen')
-rw-r--r--backend/unittests/CodeGen/MachineFrameInfoTest.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/backend/unittests/CodeGen/MachineFrameInfoTest.cpp b/backend/unittests/CodeGen/MachineFrameInfoTest.cpp
index 78987c0..b0464a6 100644
--- a/backend/unittests/CodeGen/MachineFrameInfoTest.cpp
+++ b/backend/unittests/CodeGen/MachineFrameInfoTest.cpp
@@ -57,6 +57,8 @@ void testObjectLifecycle(TestContext &Context) {
rcc::StackObjectDesc VariableDescription;
VariableDescription.Kind = rcc::StackObjectKind::VariableSized;
VariableDescription.Align = *rcc::Alignment::create(32);
+ VariableDescription.Offset = 0;
+ VariableDescription.LocalOffset = 0;
auto Variable = Frame.createObject(VariableDescription);
Context.expect(Local && Fixed && Spill && Variable, "valid stack object kinds must be created");
@@ -72,10 +74,14 @@ void testObjectLifecycle(TestContext &Context) {
Context.expect(Frame.setObjectOffset(*Local, -8).has_value() &&
Frame.setObjectOffset(*Spill, -16).has_value() &&
+ Frame.setObjectOffset(*Variable, -64).has_value() &&
Frame.markObjectDead(*Spill).has_value(),
"live stack objects must support controlled pre-freeze updates");
Context.expect(Frame.object(*Spill)->description()->IsDead,
"dead stack object state must remain explicit");
+ Context.expect(Frame.object(*Variable)->description()->Offset == -64 &&
+ Frame.object(*Variable)->description()->LocalOffset == 0,
+ "variable-sized stack objects must preserve LLVM MIR frame offsets");
Context.expect(Frame.eraseObject(*Fixed).has_value() && Frame.object(*Fixed) == nullptr &&
Frame.liveObjectCount() == 3,