@@ -336,7 +336,7 @@ func (p *lowerInterfacesPass) run() {
336
336
337
337
// Replace the old lookup/inttoptr/call with the new call.
338
338
p .builder .SetInsertPointBefore (call )
339
- retval := p .builder .CreateCall (redirector , params , "" )
339
+ retval := p .builder .CreateCall (redirector , append ( params , llvm . ConstNull ( llvm . PointerType ( p . ctx . Int8Type (), 0 ))) , "" )
340
340
if retval .Type ().TypeKind () != llvm .VoidTypeKind {
341
341
call .ReplaceAllUsesWith (retval )
342
342
}
@@ -613,9 +613,10 @@ func (p *lowerInterfacesPass) getInterfaceMethodFunc(itf *interfaceInfo, signatu
613
613
// Construct the function name, which is of the form:
614
614
// (main.Stringer).String
615
615
fnName := "(" + itf .id () + ")." + signature .methodName ()
616
- fnType := llvm .FunctionType (returnType , params , false )
616
+ fnType := llvm .FunctionType (returnType , append ( params , llvm . PointerType ( p . ctx . Int8Type (), 0 )) , false )
617
617
fn := llvm .AddFunction (p .mod , fnName , fnType )
618
- fn .LastParam ().SetName ("actualType" )
618
+ llvm .PrevParam (fn .LastParam ()).SetName ("actualType" )
619
+ fn .LastParam ().SetName ("parentHandle" )
619
620
itf .methodFuncs [signature ] = fn
620
621
return fn
621
622
}
@@ -644,13 +645,13 @@ func (p *lowerInterfacesPass) createInterfaceMethodFunc(itf *interfaceInfo, sign
644
645
645
646
// Create type switch in entry block.
646
647
p .builder .SetInsertPointAtEnd (entry )
647
- actualType := fn .LastParam ()
648
+ actualType := llvm . PrevParam ( fn .LastParam () )
648
649
sw := p .builder .CreateSwitch (actualType , defaultBlock , len (itf .types ))
649
650
650
651
// Collect the params that will be passed to the functions to call.
651
652
// These params exclude the receiver (which may actually consist of multiple
652
653
// parts).
653
- params := make ([]llvm.Value , fn .ParamsCount ()- 2 )
654
+ params := make ([]llvm.Value , fn .ParamsCount ()- 3 )
654
655
for i := range params {
655
656
params [i ] = fn .Param (i + 1 )
656
657
}
0 commit comments