Global register variable definition is removed as dead code

Pitchumani Sivanupandi pitchumani.s@hotmail.com
Wed Dec 7 05:24:00 GMT 2011


Hi,
Consider the following test case:
// gcc-4.6.1// option: -O1
register void  *ptr asm("rbx") ;
void testfn1(void* func){  ptr = func;  // removed as dead code  goto *ptr;}
When compiling with O1 option, 'ptr = func' definition is removed as dead code. But ref[1] says it should not be deleted even if it appears to be dead.
In dead code elimination (gcc/dce.c), the register definition is not checked for "global register variable".
Is gcc's behaviour is correct?
ref1: http://gcc.gnu.org/onlinedocs/gcc/Global-Reg-Vars.html
Thanks,Pitchumani.S

 		 	   		  



More information about the Gcc-help mailing list