diff options
author | Todd Neal <todd@tneal.org> | 2015-08-24 19:45:59 -0500 |
---|---|---|
committer | Todd Neal <todd@tneal.org> | 2015-10-29 23:16:27 +0000 |
commit | a92543e1a13f62add68a55a5b2c8f87e40d8a41f (patch) | |
tree | 5e882c3e7fdddbe4a61d99ead53ab612e770197a /test/inline.go | |
parent | c9b8cab16c457fec7cf897c2d37a266e60f99a25 (diff) | |
download | go-a92543e1a13f62add68a55a5b2c8f87e40d8a41f.tar.gz go-a92543e1a13f62add68a55a5b2c8f87e40d8a41f.zip |
cmd/compile: add support for a go:noinline directive
Some tests need to disable inlining of a function. It's currently done
in one of a few ways (adding a function call, an empty switch, or a
defer). Add support for a less fragile 'go:noinline' directive that
prevents inlining.
Fixes #12312
Change-Id: Ife444e13361b4a927709d81aa41e448f32eec8d4
Reviewed-on: https://go-review.googlesource.com/13911
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Diffstat (limited to 'test/inline.go')
-rw-r--r-- | test/inline.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/inline.go b/test/inline.go index 54f7b3efb1..fb20fab329 100644 --- a/test/inline.go +++ b/test/inline.go @@ -22,3 +22,12 @@ func add1(p unsafe.Pointer, x uintptr) unsafe.Pointer { // ERROR "can inline add func f(x *byte) *byte { // ERROR "can inline f" "leaking param: x to result" return add2(x, 1) // ERROR "inlining call to add2" "inlining call to add1" } + +//go:noinline +func g(x int) int { + return x + 1 +} + +func h(x int) int { // ERROR "can inline h" + return x + 2 +} |