compiler: mark stringFromRunes as nocapture/readonly

This commit is contained in:
Damian Gryski
2024-10-18 12:17:38 -07:00
committed by Ron Evans
parent 40c9c66c1d
commit 951e50c06f
2 changed files with 7 additions and 0 deletions
+3
View File
@@ -175,6 +175,9 @@ func (c *compilerContext) getFunction(fn *ssa.Function) (llvm.Type, llvm.Value)
case "runtime.stringFromBytes":
llvmFn.AddAttributeAtIndex(1, c.ctx.CreateEnumAttribute(llvm.AttributeKindID("nocapture"), 0))
llvmFn.AddAttributeAtIndex(1, c.ctx.CreateEnumAttribute(llvm.AttributeKindID("readonly"), 0))
case "runtime.stringFromRunes":
llvmFn.AddAttributeAtIndex(1, c.ctx.CreateEnumAttribute(llvm.AttributeKindID("nocapture"), 0))
llvmFn.AddAttributeAtIndex(1, c.ctx.CreateEnumAttribute(llvm.AttributeKindID("readonly"), 0))
case "runtime.trackPointer":
// This function is necessary for tracking pointers on the stack in a
// portable way (see gc_stack_portable.go). Indicate to the optimizer
+4
View File
@@ -54,6 +54,10 @@ func main() {
var buf [32]byte
s := string(buf[:])
println(len(s))
var rbuf [5]rune
s = string(rbuf[:])
println(s)
}
func derefInt(x *int) int {