From 7bcabe53caf7e35c0fa76122bfa9667cda9acbb8 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Mon, 15 Apr 2019 15:33:18 +0200 Subject: [PATCH] compiler: fix interface lowering pass It was removing some globals that still had uses left. --- compiler/interface-lowering.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/interface-lowering.go b/compiler/interface-lowering.go index 604521ee..cab5ee33 100644 --- a/compiler/interface-lowering.go +++ b/compiler/interface-lowering.go @@ -440,12 +440,18 @@ func (p *lowerInterfacesPass) run() { // numbers. for _, typ := range p.types { for _, use := range getUses(typ.typecode) { - if use.IsConstant() && use.Opcode() == llvm.PtrToInt { + if !use.IsAConstantExpr().IsNil() && use.Opcode() == llvm.PtrToInt { use.ReplaceAllUsesWith(llvm.ConstInt(p.uintptrType, typ.num, false)) } } } + // Remove stray runtime.typeInInterface globals. Required for the following + // cleanup. + for _, global := range typesInInterfaces { + global.EraseFromParentAsGlobal() + } + // Remove method sets of types. Unnecessary, but cleans up the IR for // inspection. for _, typ := range p.types {