Skip to content
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

Remove copy propagation from the native/WASM and Rust pipelines #2846

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Juvix/Compiler/Pipeline.hs
Original file line number Diff line number Diff line change
Expand Up @@ -378,5 +378,6 @@ asmToMiniC' = mapError (JuvixError @Asm.AsmError) . Asm.toReg' >=> regToMiniC' .

regToMiniC' :: (Member (Reader Asm.Options) r) => Reg.InfoTable -> Sem r C.MiniCResult
regToMiniC' tab = do
tab' <- Reg.toC tab
e <- ask
return $ C.fromReg (e ^. Asm.optLimits) tab
return $ C.fromReg (e ^. Asm.optLimits) tab'
6 changes: 2 additions & 4 deletions src/Juvix/Compiler/Reg/Data/TransformationId.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ data PipelineId

type TransformationLikeId = TransformationLikeId' TransformationId PipelineId

-- Note: this works only because for now we mark all variables as live. Liveness
-- information needs to be re-computed after copy propagation.
toCTransformations :: [TransformationId]
toCTransformations = [Cleanup, CopyPropagation]
toCTransformations = [Cleanup]

toRustTransformations :: [TransformationId]
toRustTransformations = [Cleanup, CopyPropagation]
toRustTransformations = [Cleanup]

toCasmTransformations :: [TransformationId]
toCasmTransformations = [Cleanup, CopyPropagation, SSA]
Expand Down
7 changes: 6 additions & 1 deletion test/Asm/Run/Positive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,10 @@ tests =
"Test038: Apply & argsnum"
$(mkRelDir ".")
$(mkRelFile "test038.jva")
$(mkRelFile "out/test038.out")
$(mkRelFile "out/test038.out"),
PosTest
"Test039: Copy propagation"
$(mkRelDir ".")
$(mkRelFile "test039.jva")
$(mkRelFile "out/test039.out")
]
1 change: 1 addition & 0 deletions tests/Asm/positive/out/test039.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11
42 changes: 42 additions & 0 deletions tests/Asm/positive/test039.jva
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
-- Copy propagation

-- This test will fail with the native/WASM backend if copy propagation is
-- performed on JuvixReg without adjusting the live variables.

function f(integer) {
push arg[0];
push 0;
eq;
br {
true: {
push 3;
push 4;
tsave {
tsave {
push tmp[1];
call f;
push tmp[0];
add;
ret;
};
};
};
false: {
push arg[0];
push arg[0];
push arg[0];
push arg[0];
add;
sub;
add;
push 1;
add;
ret;
};
};
}

function main() {
push 0;
tcall f;
}
Loading