[g++ 2.95.1] bigger stack with optimize

Jean-Francois MOINE d3moine@bst.bsf.alcatel.fr
Mon Dec 6 00:20:00 GMT 1999


Compiling the following source for Sparc or for PowerPC gives a bigger
stack with the '-O2' option.

Sparc
  - without -O2:
	f1__2cl:
	.LLFB1:
	        !#PROLOGUE# 0
	        save    %sp, -176, %sp
  - with -O2:
	f1__2cl:
	.LLFB1:
	        !#PROLOGUE# 0
	        save    %sp, -304, %sp

PowerPC
  - without -O2:
	f1__2cl:
	        stwu 1,-48(1)
  - with -O2:
	f1__2cl:
	        stwu 1,-64(1)

--------------------8<---------------------
/*
 * GNU c++ 2.95.1 - bigger stack with optimize
 *
 *	The stack reservation is bigger when using the -O2 option.
 *
 * The code was correct with GNU c++ 2.8.1.
 *
 * Compilation:
 *	Sparc:
 *		gcc -S thisfile.cc [-O2]
 *	PowerPC:
 *		gcc -S -msoft-float thisfile.cc [-O2]
 */

class base;
typedef void (base::*p_f)(int ii);

class base {
public:
	int v1, v2;
	base();
};

class cl : public base {
public:
	class cl *pcl;
	p_f pf;
	cl();
	virtual void fv1(int ii);
	void f1(void);
	int f2(void) {return v2 != 0;}
	void f3(p_f f);
};

extern void f4(class cl *p_cl, p_f f, int ii);

void cl::f1(void)
{
	if (v1 < 0) {
		if (v2 > 0)
			while (f2())
				f3((p_f) &cl::fv1);
		if (pf && pcl)
			f4(pcl, pf, 0);
	} else {
		if (pf && pcl)
			f4(pcl, pf, 0);
	}
}
--------------------8<---------------------

-- 
Ken ar c'hentañ		** Breizh ha Linux atav ! **
		mailto:Jean-Francois.Moine@bst.bsf.alcatel.fr
Jef		(home mailto:moinejf@free.fr )
		http://moinejf.free.fr/




More information about the Gcc-bugs mailing list