gcc/gcc/testsuite
H.J. Lu c03a554103 x86: Add -mfunction-return=
Add -mfunction-return= option to convert function return to call and
return thunks.  The default is 'keep', which keeps function return
unmodified.  'thunk' converts function return to call and return thunk.
'thunk-inline' converts function return to inlined call and return thunk.
'thunk-extern' converts function return to external call and return
thunk provided in a separate object file.  You can control this behavior
for a specific function by using the function attribute function_return.

Function return thunk is the same as memory thunk for -mindirect-branch=
where the return address is at the top of the stack:

__x86_return_thunk:
	call L2
L1:
	pause
	lfence
	jmp L1
L2:
	lea 8(%rsp), %rsp|lea 4(%esp), %esp
	ret

and function return becomes

	jmp __x86_return_thunk

-mindirect-branch= tests are updated with -mfunction-return=keep to
avoid false test failures when -mfunction-return=thunk is added to
RUNTESTFLAGS for "make check".

gcc/

	Backport from mainline
	2018-01-14  H.J. Lu  <hongjiu.lu@intel.com>

	* config/i386/i386-protos.h (ix86_output_function_return): New.
	* config/i386/i386.c (ix86_set_indirect_branch_type): Also
	set function_return_type.
	(indirect_thunk_name): Add ret_p to indicate thunk for function
	return.
	(output_indirect_thunk_function): Pass false to
	indirect_thunk_name.
	(ix86_output_indirect_branch_via_reg): Likewise.
	(ix86_output_indirect_branch_via_push): Likewise.
	(output_indirect_thunk_function): Create alias for function
	return thunk if regno < 0.
	(ix86_output_function_return): New function.
	(ix86_handle_fndecl_attribute): Handle function_return.
	(ix86_attribute_table): Add function_return.
	* config/i386/i386.h (machine_function): Add
	function_return_type.
	* config/i386/i386.md (simple_return_internal): Use
	ix86_output_function_return.
	(simple_return_internal_long): Likewise.
	* config/i386/i386.opt (mfunction-return=): New option.
	(indirect_branch): Mention -mfunction-return=.
	* doc/extend.texi: Document function_return function attribute.
	* doc/invoke.texi: Document -mfunction-return= option.

gcc/testsuite/

	Backport from mainline
	2018-01-14  H.J. Lu  <hongjiu.lu@intel.com>

	* gcc.target/i386/indirect-thunk-1.c (dg-options): Add
	-mfunction-return=keep.
	* gcc.target/i386/indirect-thunk-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-5.c: Likewise.
	* gcc.target/i386/indirect-thunk-6.c: Likewise.
	* gcc.target/i386/indirect-thunk-7.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-5.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-6.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-7.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-8.c: Likewise.
	* gcc.target/i386/indirect-thunk-bnd-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-bnd-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-bnd-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-bnd-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-5.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-6.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-7.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-5.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-6.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-7.c: Likewise.
	* gcc.target/i386/ret-thunk-1.c: New test.
	* gcc.target/i386/ret-thunk-10.c: Likewise.
	* gcc.target/i386/ret-thunk-11.c: Likewise.
	* gcc.target/i386/ret-thunk-12.c: Likewise.
	* gcc.target/i386/ret-thunk-13.c: Likewise.
	* gcc.target/i386/ret-thunk-14.c: Likewise.
	* gcc.target/i386/ret-thunk-15.c: Likewise.
	* gcc.target/i386/ret-thunk-16.c: Likewise.
	* gcc.target/i386/ret-thunk-2.c: Likewise.
	* gcc.target/i386/ret-thunk-3.c: Likewise.
	* gcc.target/i386/ret-thunk-4.c: Likewise.
	* gcc.target/i386/ret-thunk-5.c: Likewise.
	* gcc.target/i386/ret-thunk-6.c: Likewise.
	* gcc.target/i386/ret-thunk-7.c: Likewise.
	* gcc.target/i386/ret-thunk-8.c: Likewise.
	* gcc.target/i386/ret-thunk-9.c: Likewise.

i386: Don't use ASM_OUTPUT_DEF for TARGET_MACHO

ASM_OUTPUT_DEF isn't defined for TARGET_MACHO.  Use ASM_OUTPUT_LABEL to
generate the __x86_return_thunk label, instead of the set directive.
Update testcase to remove the __x86_return_thunk label check.  Since
-fno-pic is ignored on Darwin, update testcases to sscan or "push"
only on Linux.

gcc/

	Backport from mainline
	2018-01-15  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/83839
	* config/i386/i386.c (output_indirect_thunk_function): Use
	ASM_OUTPUT_LABEL, instead of ASM_OUTPUT_DEF, for TARGET_MACHO
	for  __x86.return_thunk.

gcc/testsuite/

	Backport from mainline
	2018-01-15  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/83839
	* gcc.target/i386/indirect-thunk-1.c: Scan for "push" only on
	Linux.
	* gcc.target/i386/indirect-thunk-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-7.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-5.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-6.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-7.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-7.c: Likewise.
	* gcc.target/i386/indirect-thunk-register-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-register-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-register-4.c: Likewise.
	* gcc.target/i386/ret-thunk-10.c: Likewise.
	* gcc.target/i386/ret-thunk-11.c: Likewise.
	* gcc.target/i386/ret-thunk-12.c: Likewise.
	* gcc.target/i386/ret-thunk-13.c: Likewise.
	* gcc.target/i386/ret-thunk-14.c: Likewise.
	* gcc.target/i386/ret-thunk-15.c: Likewise.
	* gcc.target/i386/ret-thunk-9.c: Don't check the
	__x86_return_thunk label.
	Scan for "push" only for Linux.

From-SVN: r256734
2018-01-16 03:10:44 -08:00
..
ada
brig.dg
c-c++-common re PR c++/83553 (compiler removes body of the for-loop, although there is a case label inside) 2017-12-23 09:43:10 +01:00
config
g++.dg backport: re PR c++/83713 (ICE in do_narrow at gcc/convert.c:474) 2018-01-09 08:53:14 +00:00
g++.old-deja Use relative line number for subsequent dg directives 2017-04-19 06:55:33 +00:00
gcc.c-torture re PR rtl-optimization/83565 (RTL combine pass yields wrong rotate result) 2018-01-12 10:20:42 +00:00
gcc.dg [arm] PR target/82975: Guard against reg_renumber being NULL in arm.h 2018-01-08 18:42:50 +00:00
gcc.misc-tests
gcc.target x86: Add -mfunction-return= 2018-01-16 03:10:44 -08:00
gcc.test-framework Use relative line number for subsequent dg directives 2017-04-19 06:55:33 +00:00
gfortran.dg backport: re PR libfortran/83811 (fortran 'e' format broken for single digit exponents) 2018-01-14 21:44:50 +00:00
gfortran.fortran-torture S/390: PR80464: Split MEM->GPR vector moves 2017-04-25 11:18:52 +00:00
gnat.dg decl.c (gnat_to_gnu_field): Do not set the alignment of the enclosing record type if it is not already set. 2017-12-14 17:05:43 +00:00
go.dg
go.go-torture/execute
go.test Backport correct Go MIPS architecture names from trunk. 2017-10-09 16:59:38 +00:00
jit.dg
lib Adapt Solaris 12 references 2017-11-21 09:31:12 +00:00
obj-c++.dg Use relative line number for subsequent dg directives 2017-04-19 06:55:33 +00:00
objc
objc-obj-c++-shared
objc.dg Use relative line number for subsequent dg directives 2017-04-19 06:55:33 +00:00
selftests
.gitattributes
ChangeLog x86: Add -mfunction-return= 2018-01-16 03:10:44 -08:00
ChangeLog-1993-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-2016
ChangeLog.graphite
ChangeLog.jit
ChangeLog.ptr
ChangeLog.tree-ssa
README
README.compat
README.gcc

README

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This is a collection of tests for GCC. For further information about
the C testsuite, see README.gcc.

The driver that runs this testsuite is called DejaGnu and you will
need a current DejaGnu snapshot, which is available from
ftp://gcc.gnu.org/pub/gcc/infrastructure, for example.

These tests are included "as is". If any of them fails, do not report
a bug.  Bug reports for DejaGnu can go to bug-dejagnu@gnu.org.
Discussion and comments about this testsuite should be sent to
gcc@gcc.gnu.org; additions and changes to should go to sent to
gcc-patches@gcc.gnu.org.

The entire testsuite is invoked by `make check` at the top level of
the GCC tree. `make check-g++` runs the C++ testsuite only.

STRUCTURE OF THE G++ TESTSUITE

  g++.dg tests:

  All new tests should be placed in an appropriate subdirectory of g++.dg.

  g++.old-deja tests:

  g++.benjamin	Tests by Benjamin Koz
  g++.bob
  g++.brendan	Tests by Brendan Kehoe
  g++.bugs
  g++.eh  	Tests for exception handling
  g++.ext  	Tests for g++ extensions
  g++.gb  	Tests by Gerald Baumgartner
  g++.jason	Tests by Jason Merill
  g++.jeff	Tests by Jeffrey A Law
  g++.martin	Tests by Martin v. Löwis
  g++.mike	Tests by Mike Stump
  g++.niklas	Tests by Niklas Hallqvist
  g++.ns  	Tests for namespaces
  g++.other
  g++.pt  	Tests for templates
  g++.rfg
  g++.robertl	Tests from gcc-bugs@gcc.gnu.org, gathered by Robert Lipe
	
Finally, some random last minute notes by Mike Stump <mrs@cygnus.com>, on
how to run tests (in the GCC 2.7 era):

	runtest --tool g++ --srcdir ./testsuite

where 

	runtest	Is the name used to invoke DejaGnu.   If DejaGnu is not
		install this will be the relative path name for runtest.

	--tool	This tells DejaGnu which tool you are testing. It is
		mainly used to find the testsuite directories for a
		particular tool when several testsuites are in the
		same directory. (like the gcc and g++ testsuites)

	--srcdir This points to the top level of the directory
		containing the sources of the testsuite. This is
		./testsuite if you are in the directory that has the
		testsuite directory.


Copyright (C) 1998-2017 Free Software Foundation, Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.