Skip to content
Permalink
Browse files

ir: remove old cgo related code

There is now a custom implementation of CGo based on libclang.
  • Loading branch information...
aykevl authored and deadprogram committed Feb 9, 2019
1 parent 07733ca commit 856e5fa179defc6f08cdcfa746e5b1b7fd87687b
Showing with 2 additions and 20 deletions.
  1. +0 −18 ir/ir.go
  2. +2 −2 ir/passes.go
@@ -187,9 +187,6 @@ func NewProgram(lprogram *loader.Program, mainPath string) *Program {
func (p *Program) AddPackage(pkg *ssa.Package) {
memberNames := make([]string, 0)
for name := range pkg.Members {
if isCGoInternal(name) {
continue
}
memberNames = append(memberNames, name)
}
sort.Strings(memberNames)
@@ -198,9 +195,6 @@ func (p *Program) AddPackage(pkg *ssa.Package) {
member := pkg.Members[name]
switch member := member.(type) {
case *ssa.Function:
if isCGoInternal(member.Name()) {
continue
}
p.addFunction(member)
case *ssa.Type:
t := &NamedType{Type: member}
@@ -438,18 +432,6 @@ func (p *Program) IsVolatile(t types.Type) bool {
}
}

// Return true if this is a CGo-internal function that can be ignored.
func isCGoInternal(name string) bool {
if strings.HasPrefix(name, "_Cgo_") || strings.HasPrefix(name, "_cgo") {
// _Cgo_ptr, _Cgo_use, _cgoCheckResult, _cgo_runtime_cgocall
return true // CGo-internal functions
}
if strings.HasPrefix(name, "__cgofn__cgo_") {
return true // CGo function pointer in global scope
}
return false
}

// Get all methods of a type.
func getAllMethods(prog *ssa.Program, typ types.Type) []*types.Selection {
ms := prog.MethodSets.MethodSet(typ)
@@ -73,7 +73,7 @@ func (p *Program) SimpleDCE() {
worklist := []*ssa.Function{main}
for _, f := range p.Functions {
if f.exported || f.Synthetic == "package initializer" || f.Pkg == runtimePkg || (f.Pkg == mathPkg && f.Pkg != nil) {
if f.flag || isCGoInternal(f.Name()) {
if f.flag {
continue
}
f.flag = true
@@ -103,7 +103,7 @@ func (p *Program) SimpleDCE() {
}
}
for _, operand := range instr.Operands(nil) {
if operand == nil || *operand == nil || isCGoInternal((*operand).Name()) {
if operand == nil || *operand == nil {
continue
}
switch operand := (*operand).(type) {

0 comments on commit 856e5fa

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.