mirror of
https://github.com/anoma/juvix.git
synced 2025-01-05 22:46:08 +03:00
Remove copy propagation from the native/WASM and Rust pipelines (#2846)
* Closes #2845 * Copy propagation is not correct without subsequent adjusting of live variables. See the comments in #2845. * Enables JuvixReg transformations in the test suite, which exposes the bug. * Adds a test in JuvixAsm crafted specifically to expose this bug.
This commit is contained in:
parent
9e6e8d8a35
commit
285b23742f
@ -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'
|
||||
|
@ -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]
|
||||
|
@ -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
tests/Asm/positive/out/test039.out
Normal file
1
tests/Asm/positive/out/test039.out
Normal file
@ -0,0 +1 @@
|
||||
11
|
42
tests/Asm/positive/test039.jva
Normal file
42
tests/Asm/positive/test039.jva
Normal file
@ -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…
Reference in New Issue
Block a user