@@ -1058,6 +1058,7 @@ func (v Value) SetVisibility(vi Visibility) { C.LLVMSetVisibility(v.C, C.LLVMVis
10581058func (v Value ) Alignment () int { return int (C .LLVMGetAlignment (v .C )) }
10591059func (v Value ) SetAlignment (a int ) { C .LLVMSetAlignment (v .C , C .unsigned (a )) }
10601060func (v Value ) SetUnnamedAddr (ua bool ) { C .LLVMSetUnnamedAddr (v .C , boolToLLVMBool (ua )) }
1061+ func (v Value ) GlobalValueType () (t Type ) { t .C = C .LLVMGlobalGetValueType (v .C ); return }
10611062
10621063// Operations on global variables
10631064func AddGlobal (m Module , t Type , name string ) (v Value ) {
@@ -1318,6 +1319,10 @@ func (v Value) CalledValue() (rv Value) {
13181319 rv .C = C .LLVMGetCalledValue (v .C )
13191320 return
13201321}
1322+ func (v Value ) CalledFunctionType () (t Type ) {
1323+ t .C = C .LLVMGetCalledFunctionType (v .C )
1324+ return
1325+ }
13211326
13221327// Operations on call instructions (only)
13231328func (v Value ) IsTailCall () bool { return C .LLVMIsTailCall (v .C ) != 0 }
@@ -1365,6 +1370,7 @@ func (v Value) Indices() []uint32 {
13651370func (v Value ) IntPredicate () IntPredicate { return IntPredicate (C .LLVMGetICmpPredicate (v .C )) }
13661371func (v Value ) FloatPredicate () FloatPredicate { return FloatPredicate (C .LLVMGetFCmpPredicate (v .C )) }
13671372
1373+
13681374//-------------------------------------------------------------------------
13691375// llvm.Builder
13701376//-------------------------------------------------------------------------
@@ -1412,11 +1418,11 @@ func (b Builder) GetCurrentDebugLocation() (loc DebugLoc) {
14121418func (b Builder ) SetInstDebugLocation (v Value ) { C .LLVMSetInstDebugLocation (b .C , v .C ) }
14131419func (b Builder ) InsertDeclare (module Module , storage Value , md Value ) Value {
14141420 f := module .NamedFunction ("llvm.dbg.declare" )
1421+ ftyp := FunctionType (VoidType (), []Type {storage .Type (), md .Type ()}, false )
14151422 if f .IsNil () {
1416- ftyp := FunctionType (VoidType (), []Type {storage .Type (), md .Type ()}, false )
14171423 f = AddFunction (module , "llvm.dbg.declare" , ftyp )
14181424 }
1419- return b .CreateCall (f , []Value {storage , md }, "" )
1425+ return b .CreateCall (ftyp , f , []Value {storage , md }, "" )
14201426}
14211427
14221428// Terminators
@@ -1865,11 +1871,11 @@ func (b Builder) CreatePHI(t Type, name string) (v Value) {
18651871 v .C = C .LLVMBuildPhi (b .C , t .C , cname )
18661872 return
18671873}
1868- func (b Builder ) CreateCall (fn Value , args []Value , name string ) (v Value ) {
1874+ func (b Builder ) CreateCall (t Type , fn Value , args []Value , name string ) (v Value ) {
18691875 cname := C .CString (name )
18701876 defer C .free (unsafe .Pointer (cname ))
18711877 ptr , nvals := llvmValueRefs (args )
1872- v .C = C .LLVMBuildCall ( b .C , fn .C , ptr , nvals , cname )
1878+ v .C = C .LLVMBuildCall2 ( b . C , t .C , fn .C , ptr , nvals , cname )
18731879 return
18741880}
18751881
0 commit comments