Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support //go:noescape #4584

Open
dgryski opened this issue Nov 6, 2024 · 0 comments
Open

support //go:noescape #4584

dgryski opened this issue Nov 6, 2024 · 0 comments

Comments

@dgryski
Copy link
Member

dgryski commented Nov 6, 2024

So this patch

diff --git a/compiler/symbol.go b/compiler/symbol.go
index 9b9b1d10..5ef6924d 100644
--- a/compiler/symbol.go
+++ b/compiler/symbol.go
@@ -33,6 +33,7 @@ type functionInfo struct {
        exported      bool       // go:export, CGo
        interrupt     bool       // go:interrupt
        nobounds      bool       // go:nobounds
+       noescape      bool       // go:noescape
        variadic      bool       // go:variadic (CGo only)
        inline        inlineType // go:inline
 }
@@ -202,7 +203,7 @@ func (c *compilerContext) getFunction(fn *ssa.Function) (llvm.Type, llvm.Value)

        // External/exported functions may not retain pointer values.
        // https://golang.org/cmd/cgo/#hdr-Passing_pointers
-       if info.exported {
+       if info.exported || info.noescape {
                if c.archFamily() == "wasm32" && len(fn.Blocks) == 0 {
                        // We need to add the wasm-import-module and the wasm-import-name
                        // attributes.
@@ -394,6 +395,10 @@ func (c *compilerContext) parsePragmas(info *functionInfo, f *ssa.Function) {
                        if hasUnsafeImport(f.Pkg.Pkg) {
                                info.nobounds = true
                        }
+               case "//go:noescape":
+                       //if hasUnsafeImport(f.Pkg.Pkg) {
+                       info.noescape = true
+                       //              }
                case "//go:variadic":
                        // The //go:variadic pragma is emitted by the CGo preprocessing
                        // pass for C variadic functions. This includes both explicit

"should" add support for //go:noescape, but looking through the runtime I feel like I need to add those annotations all through the hashmap code in order to actually tag things as non-escaping. Looking through there still seem to be a lot of places our escape analysis needs help.

(btw, the commented out code in the patch to check for hasUnsafeImport was causing a segfault in the compiler; not sure why..)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant