aboutsummaryrefslogtreecommitdiff
path: root/src/ARMeilleure/Translation/RegisterUsage.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2024-06-19 09:25:47 -0300
committerGitHub <noreply@github.com>2024-06-19 09:25:47 -0300
commitd25a084858438dd1188113efb76548916c2da9de (patch)
tree743ee3e759ce481bafd224f562aafae53119c753 /src/ARMeilleure/Translation/RegisterUsage.cs
parent311ca3c3f1719c0effeedfb8cf90d9f2675ef8a5 (diff)
JIT: Ensure entry block has no predecessors on RegisterUsage pass (#6951)
Diffstat (limited to 'src/ARMeilleure/Translation/RegisterUsage.cs')
-rw-r--r--src/ARMeilleure/Translation/RegisterUsage.cs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ARMeilleure/Translation/RegisterUsage.cs b/src/ARMeilleure/Translation/RegisterUsage.cs
index c8c25062..472b0f67 100644
--- a/src/ARMeilleure/Translation/RegisterUsage.cs
+++ b/src/ARMeilleure/Translation/RegisterUsage.cs
@@ -89,6 +89,17 @@ namespace ARMeilleure.Translation
public static void RunPass(ControlFlowGraph cfg, ExecutionMode mode)
{
+ if (cfg.Entry.Predecessors.Count != 0)
+ {
+ // We expect the entry block to have no predecessors.
+ // This is required because we have a implicit context load at the start of the function,
+ // but if there is a jump to the start of the function, the context load would trash the modified values.
+ // Here we insert a new entry block that will jump to the existing entry block.
+ BasicBlock newEntry = new BasicBlock(cfg.Blocks.Count);
+
+ cfg.UpdateEntry(newEntry);
+ }
+
// Compute local register inputs and outputs used inside blocks.
RegisterMask[] localInputs = new RegisterMask[cfg.Blocks.Count];
RegisterMask[] localOutputs = new RegisterMask[cfg.Blocks.Count];
@@ -201,7 +212,7 @@ namespace ARMeilleure.Translation
// The only block without any predecessor should be the entry block.
// It always needs a context load as it is the first block to run.
- if (block.Predecessors.Count == 0 || hasContextLoad)
+ if (block == cfg.Entry || hasContextLoad)
{
long vecMask = globalInputs[block.Index].VecMask;
long intMask = globalInputs[block.Index].IntMask;