This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Analysis of Brad's GCSE problem with computed gotos.


Michael:

> This program crashes when compiled with -O2 but not with "-O2 -fno-gcse".

After thinking about your explanation, I rewrote the code to get
the following, which runs fine with -O2:

extern void abort (void);
extern void side_effect(void);
extern int ei;
extern int * get_ip ();

int main(void)
{
  static void * table[] = {
    &&jump2 ,&&L00, &&L11, &&L22
  };
  int *ip;
  int e = 0, f = 0, state = 3;
  
  goto jump;
 L00:
  side_effect();
 L0:
  f = ip[35];
  goto L1;
 L11:
  side_effect();
 L1:
  e = ip[35];
  goto end;
 L22:
  side_effect();
 L2:
  ip = (int*)4;
  goto end;
  
 jump2:
  side_effect();
 jump:
  ei = 23;
  ip = get_ip ();
  goto *table[state];
  
 end:
  if (ip != (int*) 4 || (e+f) != 0) abort();
  return 0;
}

int ei;
 
int * get_ip ()
{
  return 0 /*&ei*/ ;
}

void side_effect(void)
{
  printf("Ha\n");
}

I started off without the calls to side_effect, I just wanted to have
empty blocks in which to put instructions during PRE, but jump analysis,
run before gcse, got rid of the unused labels and edges before gcse.
I couldn't figure out how to manipulate things in toplev so that gcse was run
with the flow graph I wanted.

I was hoping to use the multiple label trick to generate code that
gets around the gcse bug, but I guess it won't work.

Brad

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]