本文整理汇总了Golang中llvm/org/llgo/third_party/gotools/go/ssa.Value.Referrers方法的典型用法代码示例。如果您正苦于以下问题:Golang Value.Referrers方法的具体用法?Golang Value.Referrers怎么用?Golang Value.Referrers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm/org/llgo/third_party/gotools/go/ssa.Value
的用法示例。
在下文中一共展示了Value.Referrers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: canAvoidElementLoad
func (fr *frame) canAvoidElementLoad(ptr ssa.Value) bool {
for _, ref := range *ptr.Referrers() {
switch ref := ref.(type) {
case *ssa.Field:
case *ssa.Index:
if ref.X != ptr {
return false
}
// ok
default:
return false
}
}
return true
}
示例2: escapes
func escapes(val ssa.Value, bb *ssa.BasicBlock, pending []ssa.Value) bool {
for _, p := range pending {
if val == p {
return false
}
}
for _, ref := range *val.Referrers() {
switch ref := ref.(type) {
case *ssa.Phi:
// We must consider the variable to have escaped if it is
// possible for the program to see more than one "version"
// of the variable at once, as this requires the program
// to use heap allocation for the multiple versions.
//
// I (pcc) think that this is only possible (without stores)
// in the case where a phi node that (directly or indirectly)
// refers to the allocation dominates the allocation.
if ref.Block().Dominates(bb) {
return true
}
if escapes(ref, bb, append(pending, val)) {
return true
}
case *ssa.BinOp, *ssa.ChangeType, *ssa.Convert, *ssa.ChangeInterface, *ssa.MakeInterface, *ssa.Slice, *ssa.FieldAddr, *ssa.IndexAddr, *ssa.TypeAssert, *ssa.Extract:
if escapes(ref.(ssa.Value), bb, append(pending, val)) {
return true
}
case *ssa.Range, *ssa.DebugRef:
continue
case *ssa.UnOp:
if ref.Op == token.MUL || ref.Op == token.ARROW {
continue
}
if escapes(ref, bb, append(pending, val)) {
return true
}
case *ssa.Store:
if val == ref.Val {
return true
}
case *ssa.Call:
if builtin, ok := ref.Call.Value.(*ssa.Builtin); ok {
switch builtin.Name() {
case "cap", "len", "copy", "ssa:wrapnilchk":
continue
case "append":
if ref.Call.Args[0] == val && escapes(ref, bb, append(pending, val)) {
return true
}
default:
return true
}
} else {
return true
}
default:
return true
}
}
return false
}