From cb0a148cd79422675b8733aa5b79dae010ac0415 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 24 Oct 2018 12:37:47 +0200 Subject: [PATCH] compiler: fix map optimization Not all uses of a map are call instructions. Don't assume they are. TODO: investigate these uses and see whether they might be eliminated? --- compiler/optimizer.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler/optimizer.go b/compiler/optimizer.go index 394a0978..b194e388 100644 --- a/compiler/optimizer.go +++ b/compiler/optimizer.go @@ -69,10 +69,14 @@ func (c *Compiler) OptimizeMaps() { unknownUses := false // are there any uses other than setting a value? for _, use := range getUses(makeInst) { - switch use.CalledValue() { - case hashmapBinarySet, hashmapStringSet: - updateInsts = append(updateInsts, use) - default: + if use := use.IsACallInst(); !use.IsNil() { + switch use.CalledValue() { + case hashmapBinarySet, hashmapStringSet: + updateInsts = append(updateInsts, use) + default: + unknownUses = true + } + } else { unknownUses = true } }