Skip to content

Commit 3d44e39

Browse files
committed
compiler: mark stringFromBytes as nocapture/readonly to help escape analysis
Fixes #4525
1 parent d5f1953 commit 3d44e39

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

compiler/symbol.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ func (c *compilerContext) getFunction(fn *ssa.Function) (llvm.Type, llvm.Value)
172172
llvmFn.AddAttributeAtIndex(1, c.ctx.CreateEnumAttribute(llvm.AttributeKindID("nocapture"), 0))
173173
llvmFn.AddAttributeAtIndex(2, c.ctx.CreateEnumAttribute(llvm.AttributeKindID("readonly"), 0))
174174
llvmFn.AddAttributeAtIndex(2, c.ctx.CreateEnumAttribute(llvm.AttributeKindID("nocapture"), 0))
175+
case "runtime.stringFromBytes":
176+
llvmFn.AddAttributeAtIndex(1, c.ctx.CreateEnumAttribute(llvm.AttributeKindID("nocapture"), 0))
177+
llvmFn.AddAttributeAtIndex(1, c.ctx.CreateEnumAttribute(llvm.AttributeKindID("readonly"), 0))
175178
case "runtime.trackPointer":
176179
// This function is necessary for tracking pointers on the stack in a
177180
// portable way (see gc_stack_portable.go). Indicate to the optimizer

0 commit comments

Comments
 (0)