From 9b9da3133def6bd6a8ef81d464d4f6f481a5cde4 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Sat, 4 May 2024 17:46:33 +0800 Subject: [PATCH] cl: compile ssa.Function bugfix --- cl/_testrt/intgen/out.ll | 4 ++-- cl/compile.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cl/_testrt/intgen/out.ll b/cl/_testrt/intgen/out.ll index 8be54dfd..54f38550 100644 --- a/cl/_testrt/intgen/out.ll +++ b/cl/_testrt/intgen/out.ll @@ -50,7 +50,7 @@ _llgo_0: call void @main.init() %0 = alloca { ptr, ptr }, align 8 %1 = getelementptr inbounds { ptr, ptr }, ptr %0, i32 0, i32 0 - store ptr @main.Rand, ptr %1, align 8 + store ptr @rand, ptr %1, align 8 %2 = getelementptr inbounds { ptr, ptr }, ptr %0, i32 0, i32 1 store ptr null, ptr %2, align 8 %3 = load { ptr, ptr }, ptr %0, align 8 @@ -85,6 +85,6 @@ declare ptr @"github.com/goplus/llgo/internal/runtime.SliceData"(%"github.com/go declare void @"github.com/goplus/llgo/internal/runtime.init"() -declare i32 @main.Rand() +declare i32 @rand() declare i32 @printf(ptr, ...) diff --git a/cl/compile.go b/cl/compile.go index 95dcb029..26f55ebd 100644 --- a/cl/compile.go +++ b/cl/compile.go @@ -602,15 +602,15 @@ func (p *context) compileValue(b llssa.Builder, v ssa.Value) llssa.Expr { } } case *ssa.Function: - fn := p.compileFunc(p.pkg, p.goTyps, v, true) - return fn.Expr - /* - fn, ftype := p.funcOf(v) - if ftype >= llgoInstrBase { - panic("can't use llgo instruction as a value") - } + if v.Blocks != nil { + fn := p.compileFunc(p.pkg, p.goTyps, v, true) return fn.Expr - */ + } + fn, ftype := p.funcOf(v) + if ftype >= llgoInstrBase { + panic("can't use llgo instruction as a value") + } + return fn.Expr case *ssa.Global: g := p.varOf(v) return g.Expr