[PATCH] Add new built-in: __builtin_unreachable()

David Daney ddaney@caviumnetworks.com
Fri Jun 12 16:48:00 GMT 2009


Paolo Bonzini wrote:
> 
>>> Does that then still work for the original intent to mark asms that 
>>> never
>>> return as such?
> 
> And do we get for
> 
> int f(char *f)
> {
>   if (*f)
>     __builtin_unreachable ();
>   return f ? 1 : 0;
> }
> 
> no memory access and just a "return 1;"?
> 
[daney@dd_xps junk]$ cat jj.c

int f(char *f)
{
   if (*f)
     __builtin_unreachable();
   return f ? 1 : 0;
}
[daney@dd_xps junk]$ /home/daney/gccsvn/native-clean/gcc/xgcc 
-B/home/daney/gccsvn/native-clean/gcc/ -O2 -S jj.c
[daney@dd_xps junk]$ cat jj.s
	.file	"jj.c"
	.text
	.p2align 4,,15
.globl f
	.type	f, @function
f:
.LFB0:
	.cfi_startproc
	movl	$1, %eax
	ret
	.cfi_endproc
.LFE0:
	.size	f, .-f
	.ident	"GCC: (GNU) 4.5.0 20090612 (experimental) [trunk revision 148409]"
	.section	.note.GNU-stack,"",@progbits



More information about the Gcc-patches mailing list