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]
Other format: [Raw text]

[Bug target/15020] -mcpu=pentium4 generates wrong code


------- Additional Comments From rridge at csclub dot uwaterloo dot ca  2004-04-21 01:26 -------
The bug is caused by GCC moving instructions that writs to the stack
(part of the exception frame setup) to before the call that probes the stack.
 
The following test case demonstrates the problem with both on GCC 3.3.3 as
well as 3.5.0 (HEAD).  Compile with "g++ -O2 -mcpu=pentium4" or
"g++ -O2 -mtune=pentium4" as appropriate for the release.

int
foo() {
	throw 1;
}


int
main(int argc, char **) {
	char buf[1 * 1024 * 1024];
	int r = argc;
	
	/* Clobber ESI, EDI, EBP so they get pushed on the stack
	   in the prologue */
	
	asm("/* */" : "=D" (r) : "0" (r));
	asm("/* */" : "=S" (r) : "0" (r));
	asm("/* */" : "=b" (r) : "0" (r));

	try {
		foo();
	} catch(...) {
		r = 0;
	}
	return r;
}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15020


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