From 3e6f8fe1bc4c60859113bca7970b0b8db56eb442 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 3 Jun 2019 23:04:23 +0000 Subject: compiler: permit inlining references to global variables This requires tracking all references to unexported variables, so that we can make them global symbols in the object file, and can export them so that other compilations can see the right definition for their own inline bodies. This introduces a syntax for referencing names defined in other packages: a prefix, where NN is the package index. This will need to be added to gccgoimporter, but I didn't do it yet since it isn't yet possible to create an object for which gccgoimporter will see a prefix. This increases the number of inlinable functions in the standard library from 181 to 215, adding functions like context.Background. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/177920 From-SVN: r271891 --- gcc/go/gofrontend/expressions.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'gcc/go/gofrontend/expressions.h') diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index ea98fac..e17e8dc 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -1201,6 +1201,10 @@ class Expression void report_error(const char*); + // Write a name to export data. + static void + export_name(Export_function_body* efb, const Named_object*); + // Child class implements dumping to a dump context. virtual void do_dump_expression(Ast_dump_context*) const = 0; @@ -1246,6 +1250,9 @@ class Expression static Expression* convert_interface_to_type(Type*, Expression*, Location); + static Expression* + import_identifier(Import_function_body*, Location); + // The expression classification. Expression_classification classification_; // The location in the input file. @@ -1410,7 +1417,8 @@ class Var_expression : public Expression { return this; } int - do_inlining_cost() const; + do_inlining_cost() const + { return 1; } void do_export(Export_function_body*) const; -- cgit v1.1