[PATCH v2] [2/2] powerpc: Switch to generic WARN_ON()/BUG_ON()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Olof Johansson
Date: Thursday, October 18, 2007 - 7:03 pm

[POWERPC] Switch to generic WARN_ON()/BUG_ON()

Not using the ppc-specific WARN_ON/BUG_ON constructs actually saves about
4K text on a ppc64_defconfig. The main reason seems to be that prepping
the arguments to the conditional trap instructions is more work than
just doing a compare and branch.

Signed-off-by: Olof Johansson <olof@lixom.net>

Index: k.org/include/asm-powerpc/bug.h
===================================================================
--- k.org.orig/include/asm-powerpc/bug.h
+++ k.org/include/asm-powerpc/bug.h
@@ -54,12 +54,6 @@
 	".previous\n"
 #endif
 
-/*
- * BUG_ON() and WARN_ON() do their best to cooperate with compile-time
- * optimisations. However depending on the complexity of the condition
- * some compiler versions may not produce optimal results.
- */
-
 #define BUG() do {						\
 	__asm__ __volatile__(					\
 		"1:	twi 31,0,0\n"				\
@@ -69,20 +63,6 @@
 	for(;;) ;						\
 } while (0)
 
-#define BUG_ON(x) do {						\
-	if (__builtin_constant_p(x)) {				\
-		if (x)						\
-			BUG();					\
-	} else {						\
-		__asm__ __volatile__(				\
-		"1:	"PPC_TLNEI"	%4,0\n"			\
-		_EMIT_BUG_ENTRY					\
-		: : "i" (__FILE__), "i" (__LINE__), "i" (0),	\
-		  "i" (sizeof(struct bug_entry)),		\
-		  "r" ((__force long)(x)));			\
-	}							\
-} while (0)
-
 #define __WARN() do {						\
 	__asm__ __volatile__(					\
 		"1:	twi 31,0,0\n"				\
@@ -92,23 +72,6 @@
 		  "i" (sizeof(struct bug_entry)));		\
 } while (0)
 
-#define WARN_ON(x) ({						\
-	int __ret_warn_on = !!(x);				\
-	if (__builtin_constant_p(__ret_warn_on)) {		\
-		if (__ret_warn_on)				\
-			__WARN();				\
-	} else {						\
-		__asm__ __volatile__(				\
-		"1:	"PPC_TLNEI"	%4,0\n"			\
-		_EMIT_BUG_ENTRY					\
-		: : "i" (__FILE__), "i" (__LINE__),		\
-		  "i" (BUGFLAG_WARNING),			\
-		  "i" (sizeof(struct bug_entry)),		\
-		  "r" (__ret_warn_on));				\
-	}							\
-	unlikely(__ret_warn_on);				\
-})
-
 #endif /* __ASSEMBLY __ */
 #endif /* CONFIG_BUG */
 
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/2] bug.h: Introduce HAVE_ARCH_WARN, Olof Johansson, (Thu Oct 11, 10:12 am)
[PATCH 2/2] powerpc: Switch to generic WARN_ON()/BUG_ON(), Olof Johansson, (Thu Oct 11, 10:14 am)
Re: [PATCH 1/2] bug.h: Introduce HAVE_ARCH_WARN, Kyle McMartin, (Thu Oct 11, 10:20 am)
Re: [PATCH 1/2] bug.h: Introduce HAVE_ARCH_WARN, Paul Mundt, (Thu Oct 11, 7:53 pm)
Re: [PATCH 1/2] bug.h: Introduce HAVE_ARCH_WARN, Andrew Morton, (Thu Oct 18, 3:17 pm)
Re: [PATCH 1/2] bug.h: Introduce HAVE_ARCH_WARN, Olof Johansson, (Thu Oct 18, 3:34 pm)
[PATCH v2] [2/2] powerpc: Switch to generic WARN_ON()/BUG_ON(), Olof Johansson, (Thu Oct 18, 7:03 pm)