Merge pull request #105 from xushiwei/q
cl: compile ssa.Function bugfix
This commit is contained in:
@@ -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, ...)
|
||||
|
||||
@@ -25,6 +25,25 @@ import (
|
||||
"golang.org/x/tools/go/ssa"
|
||||
)
|
||||
|
||||
func TestErrCompileValue(t *testing.T) {
|
||||
defer func() {
|
||||
if r := recover(); r != "can't use llgo instruction as a value" {
|
||||
t.Fatal("TestErrCompileValue:", r)
|
||||
}
|
||||
}()
|
||||
pkg := types.NewPackage("foo", "foo")
|
||||
ctx := &context{
|
||||
goTyps: pkg,
|
||||
link: map[string]string{
|
||||
"foo.": "llgo.unreachable",
|
||||
},
|
||||
}
|
||||
ctx.compileValue(nil, &ssa.Function{
|
||||
Pkg: &ssa.Package{Pkg: pkg},
|
||||
Signature: types.NewSignatureType(nil, nil, nil, nil, nil, false),
|
||||
})
|
||||
}
|
||||
|
||||
func TestErrCompileInstrOrValue(t *testing.T) {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user