From 904fa852f664787cd9c6e6fc3e634155c9886d70 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 3 May 2020 23:40:02 +0200 Subject: [PATCH] transform: fix debug information in func lowering pass This commit fixes errors like the following: inlinable function call in a function with debug info must have a !dbg location call void @runtime.nilPanic(i8* undef, i8* null) inlinable function call in a function with debug info must have a !dbg location %24 = call fastcc %runtime._interface @"(*github.com/vugu/vugu/domrender.JSRenderer).render$1"(%"github.com/vugu/vugu.VGNode"** %19, i32 %22, i32 %23, i8* %15, i8* undef) error: optimizations caused a verification failure Not all instructions had a debug location, which apparently caused issues for the inliner. --- transform/func-lowering.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/transform/func-lowering.go b/transform/func-lowering.go index caef3842..03d1f440 100644 --- a/transform/func-lowering.go +++ b/transform/func-lowering.go @@ -225,6 +225,10 @@ func addFuncLoweringSwitch(mod llvm.Module, builder llvm.Builder, funcID, call l // in this gap. nextBlock := llvmutil.SplitBasicBlock(builder, sw, llvm.NextBasicBlock(sw.InstructionParent()), "func.next") + // Temporarily set the insert point to set the correct debug insert location + // for the builder. It got destroyed by the SplitBasicBlock call. + builder.SetInsertPointBefore(call) + // The 0 case, which is actually a nil check. nilBlock := ctx.InsertBasicBlock(nextBlock, "func.nil") builder.SetInsertPointAtEnd(nilBlock)