This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: PR driver/34904: -march=native doesn't work with multiple input files
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 21 Jan 2008 12:38:56 -0800
- Subject: PATCH: PR driver/34904: -march=native doesn't work with multiple input files
The problem is a switch can be both live and ignored. It is live
because it is true in a conditional spec. It is ignored becuse it
is used in %<. This patch changes live_cond to bits to support
this. I am testing it on Linux/ia32, Linux/Intel64 and Linux/ia64.
OK to install if there is no regression?
H.J.
---
2008-01-21 H.J. Lu <hongjiu.lu@intel.com>
PR driver/34904
* gcc.c (SWITCH_OK): Removed.
(SWITCH_LIVE): Changed to bit.
(SWITCH_FALSE): Likewise.
(SWITCH_IGNORE): Likewise.
(switchstr): Change live_cond to unsigned int.
(process_command): Replace SWITCH_OK with 0.
(do_self_spec): Likewise.
(set_collect_gcc_options): Check the SWITCH_IGNORE bit.
(give_switch): Likewise.
(used_arg): Likewise.
(do_spec_1): Set the SWITCH_IGNORE bit.
(check_live_switch): Check both SWITCH_LIVE and SWITCH_FALSE
bits. Set the SWITCH_LIVE bit.
Index: gcc/gcc.c
===================================================================
--- gcc/gcc.c (revision 1327)
+++ gcc/gcc.c (working copy)
@@ -3082,24 +3082,22 @@ See %s for instructions.",
If a switch uses following arguments, then the `part1' field
is the switch itself and the `args' field
is a null-terminated vector containing the following arguments.
- The `live_cond' field is:
- 0 when initialized
- 1 if the switch is true in a conditional spec,
- -1 if false (overridden by a later switch)
- -2 if this switch should be ignored (used in %<S)
+ Bits in the `live_cond' field are:
+ SWITCH_LIVE to indicate this switch is true in a conditional spec.
+ SWITCH_FALSE to indicate this switch is overridden by a later switch.
+ SWITCH_IGNORE to indicate this switch should be ignored (used in %<S).
The `validated' field is nonzero if any spec has looked at this switch;
if it remains zero at the end of the run, it must be meaningless. */
-#define SWITCH_OK 0
-#define SWITCH_FALSE -1
-#define SWITCH_IGNORE -2
-#define SWITCH_LIVE 1
+#define SWITCH_LIVE 0x1
+#define SWITCH_FALSE 0x2
+#define SWITCH_IGNORE 0x4
struct switchstr
{
const char *part1;
const char **args;
- int live_cond;
+ unsigned int live_cond;
unsigned char validated;
unsigned char ordering;
};
@@ -4119,7 +4117,7 @@ warranty; not even for MERCHANTABILITY o
-e0 or -e1 down into the linker. */
switches[n_switches].part1 = &argv[i][0];
switches[n_switches].args = 0;
- switches[n_switches].live_cond = SWITCH_OK;
+ switches[n_switches].live_cond = 0;
switches[n_switches].validated = 0;
n_switches++;
}
@@ -4230,7 +4228,7 @@ warranty; not even for MERCHANTABILITY o
else
switches[n_switches].args = 0;
- switches[n_switches].live_cond = SWITCH_OK;
+ switches[n_switches].live_cond = 0;
switches[n_switches].validated = 0;
switches[n_switches].ordering = 0;
/* These are always valid, since gcc.c itself understands the
@@ -4311,7 +4309,7 @@ set_collect_gcc_options (void)
first_time = FALSE;
/* Ignore elided switches. */
- if (switches[i].live_cond == SWITCH_IGNORE)
+ if ((switches[i].live_cond & SWITCH_IGNORE))
continue;
obstack_grow (&collect_obstack, "'-", 2);
@@ -4539,7 +4537,7 @@ do_self_spec (const char *spec)
sw = &switches[i + first];
sw->part1 = &argbuf[i][1];
sw->args = 0;
- sw->live_cond = SWITCH_OK;
+ sw->live_cond = 0;
sw->validated = 0;
sw->ordering = 0;
}
@@ -5289,7 +5287,7 @@ do_spec_1 (const char *spec, int inswitc
if (!strncmp (switches[i].part1, p, len - have_wildcard)
&& (have_wildcard || switches[i].part1[len] == '\0'))
{
- switches[i].live_cond = SWITCH_IGNORE;
+ switches[i].live_cond |= SWITCH_IGNORE;
switches[i].validated = 1;
}
@@ -5907,7 +5905,8 @@ check_live_switch (int switchnum, int pr
/* If we already processed this switch and determined if it was
live or not, return our past determination. */
if (switches[switchnum].live_cond != 0)
- return switches[switchnum].live_cond > 0;
+ return ((switches[switchnum].live_cond & SWITCH_LIVE)
+ && (switches[switchnum].live_cond & SWITCH_FALSE) == 0);
/* Now search for duplicate in a manner that depends on the name. */
switch (*name)
@@ -5954,7 +5953,7 @@ check_live_switch (int switchnum, int pr
}
/* Otherwise the switch is live. */
- switches[switchnum].live_cond = SWITCH_LIVE;
+ switches[switchnum].live_cond |= SWITCH_LIVE;
return 1;
}
@@ -5969,7 +5968,7 @@ check_live_switch (int switchnum, int pr
static void
give_switch (int switchnum, int omit_first_word)
{
- if (switches[switchnum].live_cond == SWITCH_IGNORE)
+ if ((switches[switchnum].live_cond & SWITCH_IGNORE))
return;
if (!omit_first_word)
@@ -7135,7 +7134,7 @@ used_arg (const char *p, int len)
mswitches
= XNEWVEC (struct mswitchstr, n_mdswitches + (n_switches ? n_switches : 1));
for (i = 0; i < n_switches; i++)
- if (switches[i].live_cond != SWITCH_IGNORE)
+ if ((switches[i].live_cond & SWITCH_IGNORE) == 0)
{
int xlen = strlen (switches[i].part1);
for (j = 0; j < cnt; j++)