本文整理汇总了Golang中llvm/org/llvm/bindings/go/llvm.Value.AddFunctionAttr方法的典型用法代码示例。如果您正苦于以下问题:Golang Value.AddFunctionAttr方法的具体用法?Golang Value.AddFunctionAttr怎么用?Golang Value.AddFunctionAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm/org/llvm/bindings/go/llvm.Value
的用法示例。
在下文中一共展示了Value.AddFunctionAttr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Apply
func (a llvmAttribute) Apply(v llvm.Value) {
if !v.IsAFunction().IsNil() {
v.AddFunctionAttr(llvm.Attribute(a))
} else {
v.AddAttribute(llvm.Attribute(a))
}
}
示例2: addCommonFunctionAttrs
func (c *compiler) addCommonFunctionAttrs(fn llvm.Value) {
fn.AddTargetDependentFunctionAttr("disable-tail-calls", "true")
fn.AddTargetDependentFunctionAttr("split-stack", "")
if attr := c.SanitizerAttribute; attr != 0 {
fn.AddFunctionAttr(attr)
}
}
示例3: bridgeRecoverFunc
// bridgeRecoverFunc creates a function that may call recover(), and creates
// a call to it from the current frame. The created function will be called
// with a boolean parameter that indicates whether it may call recover().
//
// The created function will have the same name as the current frame's function
// with "$recover" appended, having the same return types and parameters with
// an additional boolean parameter appended.
//
// A new frame will be returned for the newly created function.
func (fr *frame) bridgeRecoverFunc(llfn llvm.Value, fti functionTypeInfo) *frame {
// The bridging function must not be inlined, or the return address
// may not correspond to the source function.
llfn.AddFunctionAttr(llvm.NoInlineAttribute)
// Call __go_can_recover, passing in the function's return address.
entry := llvm.AddBasicBlock(llfn, "entry")
fr.builder.SetInsertPointAtEnd(entry)
canRecover := fr.runtime.canRecover.call(fr, fr.returnAddress(0))[0]
returnType := fti.functionType.ReturnType()
argTypes := fti.functionType.ParamTypes()
argTypes = append(argTypes, canRecover.Type())
// Create and call the $recover function.
ftiRecover := fti
ftiRecover.functionType = llvm.FunctionType(returnType, argTypes, false)
llfnRecover := ftiRecover.declare(fr.module.Module, llfn.Name()+"$recover")
fr.addCommonFunctionAttrs(llfnRecover)
llfnRecover.SetLinkage(llvm.InternalLinkage)
args := make([]llvm.Value, len(argTypes)-1, len(argTypes))
for i := range args {
args[i] = llfn.Param(i)
}
args = append(args, canRecover)
result := fr.builder.CreateCall(llfnRecover, args, "")
if returnType.TypeKind() == llvm.VoidTypeKind {
fr.builder.CreateRetVoid()
} else {
fr.builder.CreateRet(result)
}
// The $recover function must condition calls to __go_recover on
// the result of __go_can_recover passed in as an argument.
fr = newFrame(fr.unit, llfnRecover)
fr.retInf = ftiRecover.retInf
fr.canRecover = fr.function.Param(len(argTypes) - 1)
return fr
}