[RFC PATCH] powerpc: use __builtin_trap() in BUG/WARN macros.

Segher Boessenkool segher at kernel.crashing.org
Sun Aug 18 22:20:36 AEST 2019


Hi Christophe,

On Sat, Aug 17, 2019 at 06:37:50PM +0000, Christophe Leroy wrote:
>  #define BUG() do {						\
> +	__builtin_trap();					\

GCC will optimise away all code after this, it knows it is unreachable.
But you want to keep that BUG_ENTRY stuff I think?

The same will happen with a BUG_ON if the compiler can prove your
condition is always true.

>  	__asm__ __volatile__(					\
> -		"1:	twi 31,0,0\n"				\
> +		"1:\n"						\
>  		_EMIT_BUG_ENTRY					\
>  		: : "i" (__FILE__), "i" (__LINE__),		\
>  		    "i" (0), "i"  (sizeof(struct bug_entry)));	\

(GCC wil generate a different trap btw; what is called "trap" as extended
mnemonic, that is, "tw 31,0,0", not the same thing as "twi", if that
matters for the exception handler).


Segher


More information about the Linuxppc-dev mailing list