aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2016-09-23 09:55:57 +0200
committerMartin Liska <marxin@gcc.gnu.org>2016-09-23 07:55:57 +0000
commite70f01b561a3d65baba2c981a4e162967e41285f (patch)
tree510a28f026e1bf9bedf58f6d652a13fe520e0929
parentf2e81d0585673e93f4225599f190c6764ddb0fec (diff)
downloadgcc-e70f01b561a3d65baba2c981a4e162967e41285f.zip
gcc-e70f01b561a3d65baba2c981a4e162967e41285f.tar.gz
gcc-e70f01b561a3d65baba2c981a4e162967e41285f.tar.bz2
re PR target/71652 (ICE in in ix86_target_macros_internal, at config/i386/i386-c.c:187)
Fix PR target/71652 PR target/71652 * config/i386/i386.c (ix86_option_override_internal): Change signature and return false when there's an error related to arch string. (release_options_strings): New function. (ix86_valid_target_attribute_tree): Call the function. * gcc.target/i386/pr71652.c: New test. * gcc.target/i386/pr71652-2.c: New test. * gcc.target/i386/pr71652-3.c: New test. From-SVN: r240392
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/config/i386/i386.c70
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.target/i386/pr71652-2.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/pr71652-3.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/pr71652.c13
6 files changed, 102 insertions, 23 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 453413b..d3ba1c2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2016-09-23 Martin Liska <mliska@suse.cz>
+
+ PR target/71652
+ * config/i386/i386.c (ix86_option_override_internal): Change
+ signature and return false when there's an error related to
+ arch string.
+ (release_options_strings): New function.
+ (ix86_valid_target_attribute_tree): Call the function.
+
2016-09-23 Jakub Jelinek <jakub@redhat.com>
* hsa-gen.c (hsa_op_immed::hsa_op_immed Use CONSTRUCTOR_NELTS (...)
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index ff057dc..2dcd569 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -4731,9 +4731,10 @@ ix86_override_options_after_change (void)
/* Override various settings based on options. If MAIN_ARGS_P, the
options are from the command line, otherwise they are from
- attributes. */
+ attributes. Return true if there's an error related to march
+ option. */
-static void
+static bool
ix86_option_override_internal (bool main_args_p,
struct gcc_options *opts,
struct gcc_options *opts_set)
@@ -5262,16 +5263,36 @@ ix86_option_override_internal (bool main_args_p,
for (i = 0; i < pta_size; i++)
if (! strcmp (opts->x_ix86_arch_string, processor_alias_table[i].name))
{
+ if (!strcmp (opts->x_ix86_arch_string, "generic"))
+ {
+ error (main_args_p
+ ? "%<generic%> CPU can be used only for %<-mtune=%> switch"
+ : "%<generic%> CPU can be used only for "
+ "%<target(\"tune=\")%> attribute");
+ return false;
+ }
+ else if (!strcmp (opts->x_ix86_arch_string, "intel"))
+ {
+ error (main_args_p
+ ? "%<intel%> CPU can be used only for %<-mtune=%> switch"
+ : "%<intel%> CPU can be used only for "
+ "%<target(\"tune=\")%> attribute");
+ return false;
+ }
+
+ if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
+ && !(processor_alias_table[i].flags & PTA_64BIT))
+ {
+ error ("CPU you selected does not support x86-64 "
+ "instruction set");
+ return false;
+ }
+
ix86_schedule = processor_alias_table[i].schedule;
ix86_arch = processor_alias_table[i].processor;
/* Default cpu tuning to the architecture. */
ix86_tune = ix86_arch;
- if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
- && !(processor_alias_table[i].flags & PTA_64BIT))
- error ("CPU you selected does not support x86-64 "
- "instruction set");
-
if (processor_alias_table[i].flags & PTA_MMX
&& !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_MMX))
opts->x_ix86_isa_flags |= OPTION_MASK_ISA_MMX;
@@ -5469,17 +5490,7 @@ ix86_option_override_internal (bool main_args_p,
if (TARGET_X32 && (ix86_isa_flags & OPTION_MASK_ISA_MPX))
error ("Intel MPX does not support x32");
- if (!strcmp (opts->x_ix86_arch_string, "generic"))
- error (main_args_p
- ? "%<generic%> CPU can be used only for %<-mtune=%> switch"
- : "%<generic%> CPU can be used only for "
- "%<target(\"tune=\")%> attribute");
- else if (!strcmp (opts->x_ix86_arch_string, "intel"))
- error (main_args_p
- ? "%<intel%> CPU can be used only for %<-mtune=%> switch"
- : "%<intel%> CPU can be used only for "
- "%<target(\"tune=\")%> attribute");
- else if (i == pta_size)
+ if (i == pta_size)
{
error (main_args_p
? "bad value (%qs) for %<-march=%> switch"
@@ -6134,6 +6145,8 @@ ix86_option_override_internal (bool main_args_p,
ix86_parse_stringop_strategy_string (str, true);
free (str);
}
+
+ return true;
}
/* Implement the TARGET_OPTION_OVERRIDE hook. */
@@ -6728,6 +6741,15 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[],
return ret;
}
+/* Release allocated strings. */
+static void
+release_options_strings (char **option_strings)
+{
+ /* Free up memory allocated to hold the strings */
+ for (unsigned i = 0; i < IX86_FUNCTION_SPECIFIC_MAX; i++)
+ free (option_strings[i]);
+}
+
/* Return a TARGET_OPTION_NODE tree of the target options listed or NULL. */
tree
@@ -6742,7 +6764,6 @@ ix86_valid_target_attribute_tree (tree args,
int orig_arch_specified = ix86_arch_specified;
char *option_strings[IX86_FUNCTION_SPECIFIC_MAX] = { NULL, NULL };
tree t = NULL_TREE;
- int i;
struct cl_target_option *def
= TREE_TARGET_OPTION (target_option_default_node);
struct gcc_options enum_opts_set;
@@ -6803,7 +6824,12 @@ ix86_valid_target_attribute_tree (tree args,
}
/* Do any overrides, such as arch=xxx, or tune=xxx support. */
- ix86_option_override_internal (false, opts, opts_set);
+ bool r = ix86_option_override_internal (false, opts, opts_set);
+ if (!r)
+ {
+ release_options_strings (option_strings);
+ return error_mark_node;
+ }
/* Add any builtin functions with the new isa if any. */
ix86_add_new_builtins (opts->x_ix86_isa_flags);
@@ -6816,9 +6842,7 @@ ix86_valid_target_attribute_tree (tree args,
opts->x_ix86_tune_string = orig_tune_string;
opts_set->x_ix86_fpmath = orig_fpmath_set;
- /* Free up memory allocated to hold the strings */
- for (i = 0; i < IX86_FUNCTION_SPECIFIC_MAX; i++)
- free (option_strings[i]);
+ release_options_strings (option_strings);
}
return t;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index facc0d0..6b6693e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2016-09-23 Martin Liska <mliska@suse.cz>
+
+ * gcc.target/i386/pr71652.c: New test.
+ * gcc.target/i386/pr71652-2.c: New test.
+ * gcc.target/i386/pr71652-3.c: New test.
+
2016-09-23 Jakub Jelinek <jakub@redhat.com>
* lib/gcc-dg.exp (process-message): Support relative line number
diff --git a/gcc/testsuite/gcc.target/i386/pr71652-2.c b/gcc/testsuite/gcc.target/i386/pr71652-2.c
new file mode 100644
index 0000000..6c8eaf1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr71652-2.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#pragma GCC push_options
+#pragma GCC target ("arch=intel") /* { dg-error "'intel' CPU can be used only for 'target\\(\"tune=\"\\)' attribute" } */
+
+__attribute__((constructor)) void foo()
+{
+ asm ("");
+}
+
+#pragma GCC pop_options
+
+int main() { return 0; }
diff --git a/gcc/testsuite/gcc.target/i386/pr71652-3.c b/gcc/testsuite/gcc.target/i386/pr71652-3.c
new file mode 100644
index 0000000..ba99a3e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr71652-3.c
@@ -0,0 +1,14 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-march=haswell" } */
+
+#pragma GCC push_options
+#pragma GCC target ("arch=geode") /* { dg-error "CPU you selected does not support x86-64 instruction set" } */
+
+__attribute__((constructor)) void foo()
+{
+ asm ("");
+}
+
+#pragma GCC pop_options
+
+int main() { return 0; }
diff --git a/gcc/testsuite/gcc.target/i386/pr71652.c b/gcc/testsuite/gcc.target/i386/pr71652.c
new file mode 100644
index 0000000..a6b04db
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr71652.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#pragma GCC push_options
+#pragma GCC target ("arch=generic") /* { dg-error "'generic' CPU can be used only for 'target\\(\"tune=\"\\)' attribute" } */
+
+__attribute__((constructor)) void foo()
+{
+ asm ("");
+}
+
+#pragma GCC pop_options
+
+int main() { return 0; }