From 11c20a2342c69e720413def54332087ef7ab9d58 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 14 Sep 2021 00:14:17 -0700 Subject: compiler: fix random perturbance in reg allocation. At optimization level 2 or higher, an issue occurs whereby code generation exhibits instabilities. The same code is compiled slightly differently (but not incorrectly) depending on irrelevant circumstances, due to some different registers being used. * stdlib/compiler.tl (compiler eliminate-frame): Do not free the newly allocated t-registers inside a dohash loop. We have a separate list of them in order; just hand that off to free-tregs. The dohash loop is not ordered, because it traverses a hash, which is keyed by object identities; i.e. machine addresses assigned by memory allocation. --- stdlib/compiler.tl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl index 82450528..e2301296 100644 --- a/stdlib/compiler.tl +++ b/stdlib/compiler.tl @@ -914,8 +914,8 @@ ((@else . @rest) (list else)))))) (dohash (loc treg trhash) (let ((vb [vbhash loc])) - (set vb.loc treg) - me.(free-treg treg))) + (set vb.loc treg))) + me.(free-tregs tregs) (if (plusp me.loop-nest) (append (mapcar (ret ^(mov ,@1 (t 0))) (nreverse tregs)) ncode) ncode))) -- cgit v1.2.3