This is the mail archive of the gcc-bugs@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]

ICE in 20000408 with -fssa -O2



The following program causes a segmentation fault when compiled
on x86 linux with gcc-current.

Starting program: /pkg/gcc-000408/lib/gcc-lib/i586-pc-linux-gnu/2.96/cc1 -O2 -fssa t.c
 have_cpuid checkcpu
 Program received signal SIGSEGV, Segmentation fault.
 0x8109bbd in mark_set_1 (pbi=0xbffff4a0, new_dead=0xbffff490, reg=0x40115930,
     cond=0x0, insn=0x4011c340) at ../../egcs/gcc/flow.c:4147
 4147                      if (y && (BLOCK_NUM (y) == blocknum)
 (gdb) bt
 #0  0x8109bbd in mark_set_1 (pbi=0xbffff4a0, new_dead=0xbffff490,
     reg=0x40115930, cond=0x0, insn=0x4011c340) at ../../egcs/gcc/flow.c:4147
 #1  0x8109761 in mark_set_regs (pbi=0xbffff4a0, new_dead=0xbffff490,
	     x=0x40115950, insn=0x4011c340) at ../../egcs/gcc/flow.c:3920
 #2  0x8108fd7 in propagate_block (bb=0x8285f70, live=0xbffff530,
	     local_set=0x0, flags=39) at ../../egcs/gcc/flow.c:3485
 #3  0x8107cd4 in update_life_info (blocks=0x8299c48,
	     extent=UPDATE_LIFE_GLOBAL, prop_flags=39) at ../../egcs/gcc/flow.c:2732
 #4  0x810799d in life_analysis (f=0x4011aa00, nregs=65, file=0x0,
	     remove_dead_code=0) at ../../egcs/gcc/flow.c:2595
 #5  0x81e6a46 in convert_from_ssa () at ../../egcs/gcc/ssa.c:1815
 #6  0x804c75d in rest_of_compilation (decl=0x40119a00)
	     at ../../egcs/gcc/toplev.c:3074
 #7  0x81f8494 in finish_function (nested=0) at ../../egcs/gcc/c-decl.c:6499

 [...]



typedef unsigned long __u32;

enum cpu {
	IntelP5, IntelP6, AmdK6, AmdK7, Unknown
} kdba_msrtype;

static inline int have_cpuid(void)
{ 
	__u32 oflags, nflags; 
	__asm__("pushfl ; popl %0" : "=a" (oflags)); 
	nflags = oflags ^ 0x00200000; 
	__asm__("pushl %1 ; popfl ; pushfl ; popl %0" : "=r" (nflags) : "r" (nflags)); 
	return nflags == oflags; 
} 


static void checkcpu(void)
{
	__u32 name[3];
	int eax, ebx, ecx, edx;

	kdba_msrtype = Unknown;

	if (!have_cpuid()) 
		return; 

	__asm__("cpuid"
			: "=a"(eax), "=b"(name[0]), "=d"(name[1]), "=c"(name[2])
			: "a"(0));

    __asm__("cpuid"
			: "=a"(eax), "=b"(ebx), "=c"(ecx),"=d"(edx)
			: "a"(1));

	printf("%x %x %x %x\n", eax, ebx, ecx, edx);


	if (!memcmp(name, "GenuineIntel", 12)) {
		switch ((eax >> 8) & 0xF) {
		case 5:
			kdba_msrtype = IntelP5;
			break;
		case 6:
			kdba_msrtype = IntelP6;
			break;
		}
	} else if (!memcmp(name, "AuthenticAMD", 12)) { 
		unsigned model = (eax >> 8) & 0xF; 
		printf("%x\n", model);
		if (model >= 5 && model <= 9)
			kdba_msrtype = AmdK6;
		else if (model >= 9) 
			kdba_msrtype = AmdK7; 
	}
}

main()
{
	checkcpu();
	printf("%d\n", kdba_msrtype);
}

-- 
This is like TV. I don't like TV.

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