Commit 183dd130 by Ian Lance Taylor Committed by Ian Lance Taylor

compiler: Use new __builtin_init_heap_trampoline.

	PR go/47656
	* builtins.def (BUILT_IN_INIT_HEAP_TRAMPOLINE): Define.
	* builtins.c (expand_builtin_init_trampoline): Add onstack
	parameter.  Change caller.
	(expand_builtin): Handle BUILT_IN_INIT_HEAP_TRAMPOLINE.
	* tree.c (build_common_builtin_nodes): Declare
	__builtin_init_heap_trampoline.

From-SVN: r183650
parent a6bc0423
2012-01-27 Ian Lance Taylor <iant@google.com>
PR go/47656
* builtins.def (BUILT_IN_INIT_HEAP_TRAMPOLINE): Define.
* builtins.c (expand_builtin_init_trampoline): Add onstack
parameter. Change caller.
(expand_builtin): Handle BUILT_IN_INIT_HEAP_TRAMPOLINE.
* tree.c (build_common_builtin_nodes): Declare
__builtin_init_heap_trampoline.
2012-01-27 Georg-Johann Lay <avr@gjlay.de> 2012-01-27 Georg-Johann Lay <avr@gjlay.de>
* config/avr/avr-protos.h (lpm_reg_rtx, lpm_addr_reg_rtx, * config/avr/avr-protos.h (lpm_reg_rtx, lpm_addr_reg_rtx,
......
/* Expand builtin functions. /* Expand builtin functions.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
Free Software Foundation, Inc. 2012 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -4854,7 +4854,7 @@ round_trampoline_addr (rtx tramp) ...@@ -4854,7 +4854,7 @@ round_trampoline_addr (rtx tramp)
} }
static rtx static rtx
expand_builtin_init_trampoline (tree exp) expand_builtin_init_trampoline (tree exp, bool onstack)
{ {
tree t_tramp, t_func, t_chain; tree t_tramp, t_func, t_chain;
rtx m_tramp, r_tramp, r_chain, tmp; rtx m_tramp, r_tramp, r_chain, tmp;
...@@ -4871,13 +4871,16 @@ expand_builtin_init_trampoline (tree exp) ...@@ -4871,13 +4871,16 @@ expand_builtin_init_trampoline (tree exp)
m_tramp = gen_rtx_MEM (BLKmode, r_tramp); m_tramp = gen_rtx_MEM (BLKmode, r_tramp);
MEM_NOTRAP_P (m_tramp) = 1; MEM_NOTRAP_P (m_tramp) = 1;
/* The TRAMP argument should be the address of a field within the /* If ONSTACK, the TRAMP argument should be the address of a field
local function's FRAME decl. Let's see if we can fill in the within the local function's FRAME decl. Either way, let's see if
to fill in the MEM_ATTRs for this memory. */ we can fill in the MEM_ATTRs for this memory. */
if (TREE_CODE (t_tramp) == ADDR_EXPR) if (TREE_CODE (t_tramp) == ADDR_EXPR)
set_mem_attributes_minus_bitpos (m_tramp, TREE_OPERAND (t_tramp, 0), set_mem_attributes_minus_bitpos (m_tramp, TREE_OPERAND (t_tramp, 0),
true, 0); true, 0);
/* Creator of a heap trampoline is responsible for making sure the
address is aligned to at least STACK_BOUNDARY. Normally malloc
will ensure this anyhow. */
tmp = round_trampoline_addr (r_tramp); tmp = round_trampoline_addr (r_tramp);
if (tmp != r_tramp) if (tmp != r_tramp)
{ {
...@@ -4897,10 +4900,13 @@ expand_builtin_init_trampoline (tree exp) ...@@ -4897,10 +4900,13 @@ expand_builtin_init_trampoline (tree exp)
/* Generate insns to initialize the trampoline. */ /* Generate insns to initialize the trampoline. */
targetm.calls.trampoline_init (m_tramp, t_func, r_chain); targetm.calls.trampoline_init (m_tramp, t_func, r_chain);
trampolines_created = 1; if (onstack)
{
trampolines_created = 1;
warning_at (DECL_SOURCE_LOCATION (t_func), OPT_Wtrampolines, warning_at (DECL_SOURCE_LOCATION (t_func), OPT_Wtrampolines,
"trampoline generated for nested function %qD", t_func); "trampoline generated for nested function %qD", t_func);
}
return const0_rtx; return const0_rtx;
} }
...@@ -6325,7 +6331,9 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, ...@@ -6325,7 +6331,9 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
return const0_rtx; return const0_rtx;
case BUILT_IN_INIT_TRAMPOLINE: case BUILT_IN_INIT_TRAMPOLINE:
return expand_builtin_init_trampoline (exp); return expand_builtin_init_trampoline (exp, true);
case BUILT_IN_INIT_HEAP_TRAMPOLINE:
return expand_builtin_init_trampoline (exp, false);
case BUILT_IN_ADJUST_TRAMPOLINE: case BUILT_IN_ADJUST_TRAMPOLINE:
return expand_builtin_adjust_trampoline (exp); return expand_builtin_adjust_trampoline (exp);
......
/* This file contains the definitions and documentation for the /* This file contains the definitions and documentation for the
builtins used in the GNU compiler. builtins used in the GNU compiler.
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
2010, 2011 Free Software Foundation, Inc. 2010, 2011, 2012 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -740,6 +740,7 @@ DEF_C99_BUILTIN (BUILT_IN__EXIT2, "_Exit", BT_FN_VOID_INT, ATTR_NORETURN_ ...@@ -740,6 +740,7 @@ DEF_C99_BUILTIN (BUILT_IN__EXIT2, "_Exit", BT_FN_VOID_INT, ATTR_NORETURN_
/* Implementing nested functions. */ /* Implementing nested functions. */
DEF_BUILTIN_STUB (BUILT_IN_INIT_TRAMPOLINE, "__builtin_init_trampoline") DEF_BUILTIN_STUB (BUILT_IN_INIT_TRAMPOLINE, "__builtin_init_trampoline")
DEF_BUILTIN_STUB (BUILT_IN_INIT_HEAP_TRAMPOLINE, "__builtin_init_heap_trampoline")
DEF_BUILTIN_STUB (BUILT_IN_ADJUST_TRAMPOLINE, "__builtin_adjust_trampoline") DEF_BUILTIN_STUB (BUILT_IN_ADJUST_TRAMPOLINE, "__builtin_adjust_trampoline")
DEF_BUILTIN_STUB (BUILT_IN_NONLOCAL_GOTO, "__builtin_nonlocal_goto") DEF_BUILTIN_STUB (BUILT_IN_NONLOCAL_GOTO, "__builtin_nonlocal_goto")
......
...@@ -2422,8 +2422,8 @@ Gogo::make_trampoline(tree fnaddr, tree closure, Location location) ...@@ -2422,8 +2422,8 @@ Gogo::make_trampoline(tree fnaddr, tree closure, Location location)
x = save_expr(x); x = save_expr(x);
// Initialize the trampoline. // Initialize the trampoline.
tree ini = build_call_expr(builtin_decl_implicit(BUILT_IN_INIT_TRAMPOLINE), tree calldecl = builtin_decl_implicit(BUILT_IN_INIT_HEAP_TRAMPOLINE);
3, x, fnaddr, closure); tree ini = build_call_expr(calldecl, 3, x, fnaddr, closure);
// On some targets the trampoline address needs to be adjusted. For // On some targets the trampoline address needs to be adjusted. For
// example, when compiling in Thumb mode on the ARM, the address // example, when compiling in Thumb mode on the ARM, the address
......
/* Language-independent node constructors for parse phase of GNU compiler. /* Language-independent node constructors for parse phase of GNU compiler.
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2011 Free Software Foundation, Inc. 2011, 2012 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -9527,6 +9527,10 @@ build_common_builtin_nodes (void) ...@@ -9527,6 +9527,10 @@ build_common_builtin_nodes (void)
local_define_builtin ("__builtin_init_trampoline", ftype, local_define_builtin ("__builtin_init_trampoline", ftype,
BUILT_IN_INIT_TRAMPOLINE, BUILT_IN_INIT_TRAMPOLINE,
"__builtin_init_trampoline", ECF_NOTHROW | ECF_LEAF); "__builtin_init_trampoline", ECF_NOTHROW | ECF_LEAF);
local_define_builtin ("__builtin_init_heap_trampoline", ftype,
BUILT_IN_INIT_HEAP_TRAMPOLINE,
"__builtin_init_heap_trampoline",
ECF_NOTHROW | ECF_LEAF);
ftype = build_function_type_list (ptr_type_node, ptr_type_node, NULL_TREE); ftype = build_function_type_list (ptr_type_node, ptr_type_node, NULL_TREE);
local_define_builtin ("__builtin_adjust_trampoline", ftype, local_define_builtin ("__builtin_adjust_trampoline", ftype,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment