From 2903750a4c340fe8ca4a8447fb862281338e26d5 Mon Sep 17 00:00:00 2001 From: Matthew Fluet Date: Thu, 31 Aug 2023 18:48:14 +0000 Subject: [PATCH] Fix `RegisterAllocation.toAddressMemLoc:disp` internal compiler error Fix bug in x86 and amd64 native codegens leading to an internal compiler error (`Fail: amd64AllocateRegisters.RegisterAllocation.toAddressMemLoc:disp`). Thanks to Darin Minamoto (DarinM223) for the bug report. Closes MLton/mlton#509 --- CHANGELOG.adoc | 13 ++++++++++--- .../amd64-codegen/amd64-allocate-registers.fun | 4 +++- .../codegen/x86-codegen/x86-allocate-registers.fun | 4 +++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 2f825554d6..11360edf54 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -8,9 +8,16 @@ Here are the changes from version 20210117 to YYYYMMDD. === Details -* 2023-0-728 - ** Fix bug in `Date.localOffset` for time zones east of prime meridian. - Thanks to Arata Mizuki (minoki) for the bug report and suggested fix. +* 2023-08-31 + ** Fix bug in x86 and amd64 native codegens leading to an internal + compiler error + (`Fail: amd64AllocateRegisters.RegisterAllocation.toAddressMemLoc:disp`). + Thanks to Darin Minamoto (DarinM223) for the bug report. + +* 2023-07-28 + ** Fix bug in `Date.localOffset` for time zones east of prime + meridian. Thanks to Arata Mizuki (minoki) for the bug report and + suggested fix. * 2023-05-29 ** Fix bugs in `WORD.scan` when `0` is followed by `w` or `x` or diff --git a/mlton/codegen/amd64-codegen/amd64-allocate-registers.fun b/mlton/codegen/amd64-codegen/amd64-allocate-registers.fun index 5f78e88a12..a46cb5fabc 100644 --- a/mlton/codegen/amd64-codegen/amd64-allocate-registers.fun +++ b/mlton/codegen/amd64-codegen/amd64-allocate-registers.fun @@ -1,4 +1,4 @@ -(* Copyright (C) 2010,2020 Matthew Fluet. +(* Copyright (C) 2010,2020,2023 Matthew Fluet. * Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh * Jagannathan, and Stephen Weeks. * Copyright (C) 1997-2000 NEC Research Institute. @@ -3775,6 +3775,8 @@ struct Immediate.labelPlusWord (l1, w2) | (Immediate.LabelPlusWord (l1, w1), Immediate.Word w2) => Immediate.labelPlusWord (l1, WordX.add (w1, w2)) + | (Immediate.Word w1, Immediate.Word w2) => + Immediate.word (WordX.add (w1, w2)) | _ => Error.bug "amd64AllocateRegisters.RegisterAllocation.toAddressMemLoc:disp") (* The base register gets supplied by three distinct cases: diff --git a/mlton/codegen/x86-codegen/x86-allocate-registers.fun b/mlton/codegen/x86-codegen/x86-allocate-registers.fun index cd0b023ebc..a747ad7106 100644 --- a/mlton/codegen/x86-codegen/x86-allocate-registers.fun +++ b/mlton/codegen/x86-codegen/x86-allocate-registers.fun @@ -1,4 +1,4 @@ -(* Copyright (C) 2010,2020 Matthew Fluet. +(* Copyright (C) 2010,2020,2023 Matthew Fluet. * Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh * Jagannathan, and Stephen Weeks. * Copyright (C) 1997-2000 NEC Research Institute. @@ -3501,6 +3501,8 @@ struct Immediate.labelPlusWord (mungeLabel l1, w2) | (Immediate.LabelPlusWord (l1, w1), Immediate.Word w2) => Immediate.labelPlusWord (mungeLabel l1, WordX.add (w1, w2)) + | (Immediate.Word w1, Immediate.Word w2) => + Immediate.word (WordX.add (w1, w2)) | _ => Error.bug "x86AllocateRegisters.RegisterAllocation.toAddressMemLoc:disp") val {register = register_base,