@@ -167,11 +167,10 @@ func (c *Compiler) TargetData() llvm.TargetData {
167
167
168
168
// selectGC picks an appropriate GC strategy if none was provided.
169
169
func (c * Compiler ) selectGC () string {
170
- gc := c .GC
171
- if gc == "" {
172
- gc = "leaking"
170
+ if c .GC != "" {
171
+ return c .GC
173
172
}
174
- return gc
173
+ return "conservative"
175
174
}
176
175
177
176
// Compile the given package path or .go file path. Return an error when this
@@ -362,6 +361,15 @@ func (c *Compiler) Compile(mainPath string) []error {
362
361
// See emitNilCheck in asserts.go.
363
362
c .mod .NamedFunction ("runtime.isnil" ).AddAttributeAtIndex (1 , nocapture )
364
363
364
+ // This function is necessary for tracking pointers on the stack in a
365
+ // portable way (see gc.go). Indicate to the optimizer that the only thing
366
+ // we'll do is read the pointer.
367
+ trackPointer := c .mod .NamedFunction ("runtime.trackPointer" )
368
+ if ! trackPointer .IsNil () {
369
+ trackPointer .AddAttributeAtIndex (1 , nocapture )
370
+ trackPointer .AddAttributeAtIndex (1 , readonly )
371
+ }
372
+
365
373
// Memory copy operations do not capture pointers, even though some weird
366
374
// pointer arithmetic is happening in the Go implementation.
367
375
for _ , fnName := range []string {"runtime.memcpy" , "runtime.memmove" } {
@@ -1009,6 +1017,9 @@ func (c *Compiler) parseInstr(frame *Frame, instr ssa.Instruction) {
1009
1017
frame .locals [instr ] = llvm .Undef (c .getLLVMType (instr .Type ()))
1010
1018
} else {
1011
1019
frame .locals [instr ] = value
1020
+ if len (* instr .Referrers ()) != 0 && c .needsStackObjects () {
1021
+ c .trackExpr (frame , instr , value )
1022
+ }
1012
1023
}
1013
1024
case * ssa.DebugRef :
1014
1025
// ignore
0 commit comments