github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/unused/runtime.go (about)

     1  package unused
     2  
     3  // Functions defined in the Go runtime that may be called through
     4  // compiler magic or via assembly.
     5  var runtimeFuncs = map[string]bool{
     6  	// Copied from cmd/compile/internal/typecheck/builtin.go, var runtimeDecls
     7  	"newobject":               true,
     8  	"panicindex":              true,
     9  	"panicslice":              true,
    10  	"panicdivide":             true,
    11  	"panicmakeslicelen":       true,
    12  	"throwinit":               true,
    13  	"panicwrap":               true,
    14  	"gopanic":                 true,
    15  	"gorecover":               true,
    16  	"goschedguarded":          true,
    17  	"printbool":               true,
    18  	"printfloat":              true,
    19  	"printint":                true,
    20  	"printhex":                true,
    21  	"printuint":               true,
    22  	"printcomplex":            true,
    23  	"printstring":             true,
    24  	"printpointer":            true,
    25  	"printiface":              true,
    26  	"printeface":              true,
    27  	"printslice":              true,
    28  	"printnl":                 true,
    29  	"printsp":                 true,
    30  	"printlock":               true,
    31  	"printunlock":             true,
    32  	"concatstring2":           true,
    33  	"concatstring3":           true,
    34  	"concatstring4":           true,
    35  	"concatstring5":           true,
    36  	"concatstrings":           true,
    37  	"cmpstring":               true,
    38  	"intstring":               true,
    39  	"slicebytetostring":       true,
    40  	"slicebytetostringtmp":    true,
    41  	"slicerunetostring":       true,
    42  	"stringtoslicebyte":       true,
    43  	"stringtoslicerune":       true,
    44  	"slicecopy":               true,
    45  	"slicestringcopy":         true,
    46  	"decoderune":              true,
    47  	"countrunes":              true,
    48  	"convI2I":                 true,
    49  	"convT16":                 true,
    50  	"convT32":                 true,
    51  	"convT64":                 true,
    52  	"convTstring":             true,
    53  	"convTslice":              true,
    54  	"convT2E":                 true,
    55  	"convT2Enoptr":            true,
    56  	"convT2I":                 true,
    57  	"convT2Inoptr":            true,
    58  	"assertE2I":               true,
    59  	"assertE2I2":              true,
    60  	"assertI2I":               true,
    61  	"assertI2I2":              true,
    62  	"panicdottypeE":           true,
    63  	"panicdottypeI":           true,
    64  	"panicnildottype":         true,
    65  	"ifaceeq":                 true,
    66  	"efaceeq":                 true,
    67  	"fastrand":                true,
    68  	"makemap64":               true,
    69  	"makemap":                 true,
    70  	"makemap_small":           true,
    71  	"mapaccess1":              true,
    72  	"mapaccess1_fast32":       true,
    73  	"mapaccess1_fast64":       true,
    74  	"mapaccess1_faststr":      true,
    75  	"mapaccess1_fat":          true,
    76  	"mapaccess2":              true,
    77  	"mapaccess2_fast32":       true,
    78  	"mapaccess2_fast64":       true,
    79  	"mapaccess2_faststr":      true,
    80  	"mapaccess2_fat":          true,
    81  	"mapassign":               true,
    82  	"mapassign_fast32":        true,
    83  	"mapassign_fast32ptr":     true,
    84  	"mapassign_fast64":        true,
    85  	"mapassign_fast64ptr":     true,
    86  	"mapassign_faststr":       true,
    87  	"mapiterinit":             true,
    88  	"mapdelete":               true,
    89  	"mapdelete_fast32":        true,
    90  	"mapdelete_fast64":        true,
    91  	"mapdelete_faststr":       true,
    92  	"mapiternext":             true,
    93  	"mapclear":                true,
    94  	"makechan64":              true,
    95  	"makechan":                true,
    96  	"chanrecv1":               true,
    97  	"chanrecv2":               true,
    98  	"chansend1":               true,
    99  	"closechan":               true,
   100  	"writeBarrier":            true,
   101  	"typedmemmove":            true,
   102  	"typedmemclr":             true,
   103  	"typedslicecopy":          true,
   104  	"selectnbsend":            true,
   105  	"selectnbrecv":            true,
   106  	"selectnbrecv2":           true,
   107  	"selectsetpc":             true,
   108  	"selectgo":                true,
   109  	"block":                   true,
   110  	"makeslice":               true,
   111  	"makeslice64":             true,
   112  	"growslice":               true,
   113  	"memmove":                 true,
   114  	"memclrNoHeapPointers":    true,
   115  	"memclrHasPointers":       true,
   116  	"memequal":                true,
   117  	"memequal8":               true,
   118  	"memequal16":              true,
   119  	"memequal32":              true,
   120  	"memequal64":              true,
   121  	"memequal128":             true,
   122  	"int64div":                true,
   123  	"uint64div":               true,
   124  	"int64mod":                true,
   125  	"uint64mod":               true,
   126  	"float64toint64":          true,
   127  	"float64touint64":         true,
   128  	"float64touint32":         true,
   129  	"int64tofloat64":          true,
   130  	"uint64tofloat64":         true,
   131  	"uint32tofloat64":         true,
   132  	"complex128div":           true,
   133  	"racefuncenter":           true,
   134  	"racefuncenterfp":         true,
   135  	"racefuncexit":            true,
   136  	"raceread":                true,
   137  	"racewrite":               true,
   138  	"racereadrange":           true,
   139  	"racewriterange":          true,
   140  	"msanread":                true,
   141  	"msanwrite":               true,
   142  	"x86HasPOPCNT":            true,
   143  	"x86HasSSE41":             true,
   144  	"arm64HasATOMICS":         true,
   145  	"mallocgc":                true,
   146  	"panicshift":              true,
   147  	"panicmakeslicecap":       true,
   148  	"goPanicIndex":            true,
   149  	"goPanicIndexU":           true,
   150  	"goPanicSliceAlen":        true,
   151  	"goPanicSliceAlenU":       true,
   152  	"goPanicSliceAcap":        true,
   153  	"goPanicSliceAcapU":       true,
   154  	"goPanicSliceB":           true,
   155  	"goPanicSliceBU":          true,
   156  	"goPanicSlice3Alen":       true,
   157  	"goPanicSlice3AlenU":      true,
   158  	"goPanicSlice3Acap":       true,
   159  	"goPanicSlice3AcapU":      true,
   160  	"goPanicSlice3B":          true,
   161  	"goPanicSlice3BU":         true,
   162  	"goPanicSlice3C":          true,
   163  	"goPanicSlice3CU":         true,
   164  	"goPanicSliceConvert":     true,
   165  	"printuintptr":            true,
   166  	"convT":                   true,
   167  	"convTnoptr":              true,
   168  	"makeslicecopy":           true,
   169  	"unsafeslicecheckptr":     true,
   170  	"panicunsafeslicelen":     true,
   171  	"panicunsafeslicenilptr":  true,
   172  	"unsafestringcheckptr":    true,
   173  	"panicunsafestringlen":    true,
   174  	"panicunsafestringnilptr": true,
   175  	"mulUintptr":              true,
   176  	"memequal0":               true,
   177  	"f32equal":                true,
   178  	"f64equal":                true,
   179  	"c64equal":                true,
   180  	"c128equal":               true,
   181  	"strequal":                true,
   182  	"interequal":              true,
   183  	"nilinterequal":           true,
   184  	"memhash":                 true,
   185  	"memhash0":                true,
   186  	"memhash8":                true,
   187  	"memhash16":               true,
   188  	"memhash32":               true,
   189  	"memhash64":               true,
   190  	"memhash128":              true,
   191  	"f32hash":                 true,
   192  	"f64hash":                 true,
   193  	"c64hash":                 true,
   194  	"c128hash":                true,
   195  	"strhash":                 true,
   196  	"interhash":               true,
   197  	"nilinterhash":            true,
   198  	"int64tofloat32":          true,
   199  	"uint64tofloat32":         true,
   200  	"getcallerpc":             true,
   201  	"getcallersp":             true,
   202  	"msanmove":                true,
   203  	"asanread":                true,
   204  	"asanwrite":               true,
   205  	"checkptrAlignment":       true,
   206  	"checkptrArithmetic":      true,
   207  	"libfuzzerTraceCmp1":      true,
   208  	"libfuzzerTraceCmp2":      true,
   209  	"libfuzzerTraceCmp4":      true,
   210  	"libfuzzerTraceCmp8":      true,
   211  	"libfuzzerTraceConstCmp1": true,
   212  	"libfuzzerTraceConstCmp2": true,
   213  	"libfuzzerTraceConstCmp4": true,
   214  	"libfuzzerTraceConstCmp8": true,
   215  	"libfuzzerHookStrCmp":     true,
   216  	"libfuzzerHookEqualFold":  true,
   217  	"addCovMeta":              true,
   218  	"x86HasFMA":               true,
   219  	"armHasVFPv4":             true,
   220  
   221  	// Extracted from assembly code in the standard library, with the exception of the runtime package itself
   222  	"abort":                 true,
   223  	"aeshashbody":           true,
   224  	"args":                  true,
   225  	"asminit":               true,
   226  	"badctxt":               true,
   227  	"badmcall2":             true,
   228  	"badmcall":              true,
   229  	"badmorestackg0":        true,
   230  	"badmorestackgsignal":   true,
   231  	"badsignal2":            true,
   232  	"callbackasm1":          true,
   233  	"callCfunction":         true,
   234  	"cgocallback_gofunc":    true,
   235  	"cgocallbackg":          true,
   236  	"checkgoarm":            true,
   237  	"check":                 true,
   238  	"debugCallCheck":        true,
   239  	"debugCallWrap":         true,
   240  	"emptyfunc":             true,
   241  	"entersyscall":          true,
   242  	"exit":                  true,
   243  	"exits":                 true,
   244  	"exitsyscall":           true,
   245  	"externalthreadhandler": true,
   246  	"findnull":              true,
   247  	"goexit1":               true,
   248  	"gostring":              true,
   249  	"i386_set_ldt":          true,
   250  	"_initcgo":              true,
   251  	"init_thread_tls":       true,
   252  	"ldt0setup":             true,
   253  	"libpreinit":            true,
   254  	"load_g":                true,
   255  	"morestack":             true,
   256  	"mstart":                true,
   257  	"nacl_sysinfo":          true,
   258  	"nanotimeQPC":           true,
   259  	"nanotime":              true,
   260  	"newosproc0":            true,
   261  	"newproc":               true,
   262  	"newstack":              true,
   263  	"noted":                 true,
   264  	"nowQPC":                true,
   265  	"osinit":                true,
   266  	"printf":                true,
   267  	"racecallback":          true,
   268  	"reflectcallmove":       true,
   269  	"reginit":               true,
   270  	"rt0_go":                true,
   271  	"save_g":                true,
   272  	"schedinit":             true,
   273  	"setldt":                true,
   274  	"settls":                true,
   275  	"sighandler":            true,
   276  	"sigprofNonGo":          true,
   277  	"sigtrampgo":            true,
   278  	"_sigtramp":             true,
   279  	"sigtramp":              true,
   280  	"stackcheck":            true,
   281  	"syscall_chdir":         true,
   282  	"syscall_chroot":        true,
   283  	"syscall_close":         true,
   284  	"syscall_dup2":          true,
   285  	"syscall_execve":        true,
   286  	"syscall_exit":          true,
   287  	"syscall_fcntl":         true,
   288  	"syscall_forkx":         true,
   289  	"syscall_gethostname":   true,
   290  	"syscall_getpid":        true,
   291  	"syscall_ioctl":         true,
   292  	"syscall_pipe":          true,
   293  	"syscall_rawsyscall6":   true,
   294  	"syscall_rawSyscall6":   true,
   295  	"syscall_rawsyscall":    true,
   296  	"syscall_RawSyscall":    true,
   297  	"syscall_rawsysvicall6": true,
   298  	"syscall_setgid":        true,
   299  	"syscall_setgroups":     true,
   300  	"syscall_setpgid":       true,
   301  	"syscall_setsid":        true,
   302  	"syscall_setuid":        true,
   303  	"syscall_syscall6":      true,
   304  	"syscall_syscall":       true,
   305  	"syscall_Syscall":       true,
   306  	"syscall_sysvicall6":    true,
   307  	"syscall_wait4":         true,
   308  	"syscall_write":         true,
   309  	"traceback":             true,
   310  	"tstart":                true,
   311  	"usplitR0":              true,
   312  	"wbBufFlush":            true,
   313  	"write":                 true,
   314  
   315  	// Other runtime functions that can get called in non-standard ways
   316  	"bgsweep":             true,
   317  	"memhash_varlen":      true,
   318  	"strhashFallback":     true,
   319  	"asanregisterglobals": true,
   320  	"cgoUse":              true,
   321  	"cgoCheckPointer":     true,
   322  	"cgoCheckResult":      true,
   323  	"_cgo_panic_internal": true,
   324  	"addExitHook":         true,
   325  }
   326  
   327  var runtimeCoverageFuncs = map[string]bool{
   328  	"initHook":            true,
   329  	"markProfileEmitted":  true,
   330  	"processCoverTestDir": true,
   331  }