MIPS branching too far

Colin Burgess cburgess@qnx.com
Thu Sep 20 13:23:00 GMT 2001


I think I've found a problem with the mips compiler (at least
in 2.95.2, and I think it's still in the latest as well).

There's a file in mozilla called nsPrefMigration.cpp that has a
method called ProcessPrefsCallback.  This (at least on our
system, which is QNX Neutrino 6.1 using the Dinkum C++ headers)
tickles a nasty bug.

Basically, the problem is this...

Say you have a function of the form...

int func(void)
{
lots of objects created on stack
int ret;


	ret = some_func_1();
	if ( ret & condition ) return ret;
	...
	ret = some_func_n();
	if ( ret & condition ) return ret;

	return ret;
}

then the compiler (without optimising) produces something like

func prologue
run object constructors

	call some_func_1
	test and jump to label2
	run object destructors
	jmp to label1

label2:
	call some_func_2
	test and jump to label3
	run object destructors
	jmp to label1

	...

label1:
func epilogue

Now the problem I'm seeing is that since I'm compiling this PIC,
then the jmp to label1 is being transformed by the assembler into
a branch, and the jump distance is just too long for a branch.

So my first question is: is this a bug in cc1plus, as or both?
And more to the point - has anyone got any good ideas about how
to fix this?

Thanks for any help,

Colin Burgess

-- 
cburgess@qnx.com



More information about the Gcc-bugs mailing list