diff mbox

[committed,PR64707] Make fopenmp an LTO option

Message ID 54C266FE.8000007@mentor.com
State New
Headers show

Commit Message

Tom de Vries Jan. 23, 2015, 3:21 p.m. UTC
Hi,

This patch fixes PR64707.

It marks fopenmp as LTO option, which enables openmp builtins in lto1.

Bootstrapped, reg-tested on x86_64 and committed.

Thanks,
- Tom
diff mbox

Patch

2015-01-22  Tom de Vries  <tom@codesourcery.com>

	PR libgomp/64707
	* lto-opts.c (lto_write_options): Output non-explicit conservative
	-fno-openmp.
	* lto-wrapper.c (merge_and_complain): Handle merging -fopenmp.
	(append_compiler_options): Pass -fopenmp through.

	* c.opt (fopenmp): Mark as LTO option.

	* lang.opt (fopenmp): Mark as LTO option.

	* testsuite/libgomp.c/target-9.c: Add -ftree-parallelize-loops=0 to
	dg-options.
---
 gcc/c-family/c.opt                     | 2 +-
 gcc/fortran/lang.opt                   | 2 +-
 gcc/lto-opts.c                         | 4 ++++
 gcc/lto-wrapper.c                      | 2 ++
 libgomp/testsuite/libgomp.c/target-9.c | 2 +-
 5 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 62b6c685..4b92022 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -1288,7 +1288,7 @@  C ObjC C++ ObjC++ Var(flag_openacc)
 Enable OpenACC
 
 fopenmp
-C ObjC C++ ObjC++ Var(flag_openmp)
+C ObjC C++ ObjC++ LTO Var(flag_openmp)
 Enable OpenMP (implies -frecursive in Fortran)
 
 fopenmp-simd
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
index a7a4ed6..0360f6c 100644
--- a/gcc/fortran/lang.opt
+++ b/gcc/fortran/lang.opt
@@ -571,7 +571,7 @@  Fortran
 ; Documented in C
 
 fopenmp
-Fortran
+Fortran LTO
 ; Documented in C
 
 fopenmp-simd
diff --git a/gcc/lto-opts.c b/gcc/lto-opts.c
index 026b323..d44dba0 100644
--- a/gcc/lto-opts.c
+++ b/gcc/lto-opts.c
@@ -166,6 +166,10 @@  lto_write_options (void)
     append_to_collect_gcc_options (&temporary_obstack, &first_p,
 			       "-fno-strict-overflow");
 
+  if (!global_options_set.x_flag_openmp
+      && !global_options.x_flag_openmp)
+    append_to_collect_gcc_options (&temporary_obstack, &first_p, "-fno-openmp");
+
   /* Append options from target hook and store them to offload_lto section.  */
   if (lto_stream_offload_p)
     {
diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index b1efed2..2d0d451 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -271,6 +271,7 @@  merge_and_complain (struct cl_decoded_option **decoded_options,
 	case OPT_fsigned_zeros:
 	case OPT_ftrapping_math:
 	case OPT_fwrapv:
+	case OPT_fopenmp:
 	  /* For selected options we can merge conservatively.  */
 	  for (j = 0; j < *decoded_options_count; ++j)
 	    if ((*decoded_options)[j].opt_index == foption->opt_index)
@@ -490,6 +491,7 @@  append_compiler_options (obstack *argv_obstack, struct cl_decoded_option *opts,
 	case OPT_fsigned_zeros:
 	case OPT_ftrapping_math:
 	case OPT_fwrapv:
+	case OPT_fopenmp:
 	case OPT_ftrapv:
 	case OPT_fstrict_overflow:
 	case OPT_foffload_abi_:
diff --git a/libgomp/testsuite/libgomp.c/target-9.c b/libgomp/testsuite/libgomp.c/target-9.c
index 00fe0cb..4f3c812 100644
--- a/libgomp/testsuite/libgomp.c/target-9.c
+++ b/libgomp/testsuite/libgomp.c/target-9.c
@@ -1,5 +1,5 @@ 
 /* { dg-do run } */
-/* { dg-options "-O1" } */
+/* { dg-options "-O1 -ftree-parallelize-loops=0" } */
 /* { dg-additional-options "-flto" { target lto } } */
 
 #include <stdlib.h>
-- 
1.9.1