From aa4d56e2ce1d89599654d33051486cb58aadbc2e Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 19 Jul 2019 23:10:55 +0000 Subject: [PATCH] compiler: don't export bodies for functions marked "go:noinline" The current Mark_inline_candidates helper looks only at budget when deciding to mark a function or method as inline (with the proviso that IR constructs not yet supported by the inliner are given artificially high cost). This patch changes the helper to also look at whether a function has the "go:noinline" pragma; if it does have the pragma there is no point putting it into the export data (it will just make the export data bigger). Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/186923 From-SVN: r273611 --- gcc/go/gofrontend/MERGE | 2 +- gcc/go/gofrontend/gogo.cc | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index ccc1a24be26..2c536025f28 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -4df7c8d7af894ee93f50c3a50debdcf4e369a2c6 +e242929304e7a524ced56dc94605bbf6d83e6489 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index abd86868bee..30523f7209a 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -5109,6 +5109,8 @@ int Mark_inline_candidates::function(Named_object* no) { Function* func = no->func_value(); + if ((func->pragmas() & GOPRAGMA_NOINLINE) != 0) + return TRAVERSE_CONTINUE; int budget = budget_heuristic; Inline_within_budget iwb(&budget); func->block()->traverse(&iwb); @@ -5138,6 +5140,8 @@ Mark_inline_candidates::type(Type* t) Named_object* no = *p; go_assert(no->is_function()); Function *func = no->func_value(); + if ((func->pragmas() & GOPRAGMA_NOINLINE) != 0) + continue; int budget = budget_heuristic; Inline_within_budget iwb(&budget); func->block()->traverse(&iwb); -- 2.30.2