Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
zerosize.go45 linesDownload Raw Back to codegen
1// asmcheck2 3// Copyright 2018 The Go Authors. All rights reserved.4// Use of this source code is governed by a BSD-style5// license that can be found in the LICENSE file.6 7// Make sure a pointer variable and a zero-sized variable8// aren't allocated to the same stack slot.9// See issue 24993.10 11package codegen12 13func zeroSize() {14	c := make(chan struct{})15	// amd64:`MOVQ \$0, command-line-arguments\.s\+56\(SP\)`16	var s *int17	// force s to be a stack object, also use some (fixed) stack space18	g(&s, 1, 2, 3, 4, 5)19 20	// amd64:`LEAQ command-line-arguments\..*\+55\(SP\)`21	c <- noliteral(struct{}{})22}23 24// Like zeroSize, but without hiding the zero-sized struct.25func zeroSize2() {26	c := make(chan struct{})27	// amd64:`MOVQ \$0, command-line-arguments\.s\+48\(SP\)`28	var s *int29	// force s to be a stack object, also use some (fixed) stack space30	g(&s, 1, 2, 3, 4, 5)31 32	// amd64:`LEAQ command-line-arguments\..*stmp_\d+\(SB\)`33	c <- struct{}{}34}35 36//go:noinline37func g(**int, int, int, int, int, int) {}38 39// noliteral prevents the compiler from recognizing a literal value.40//41//go:noinline42func noliteral[T any](t T) T {43	return t44}45 
codekingpro/portable-devtools · Team Ai