Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'compiler-attributes-for-linus-v5.4' of git://github.com/ojeda/linux

Pull asm inline support from Miguel Ojeda:
"Make use of gcc 9's "asm inline()" (Rasmus Villemoes):

gcc 9+ (and gcc 8.3, 7.5) provides a way to override the otherwise
crude heuristic that gcc uses to estimate the size of the code
represented by an asm() statement. From the gcc docs

If you use 'asm inline' instead of just 'asm', then for inlining
purposes the size of the asm is taken as the minimum size, ignoring
how many instructions GCC thinks it is.

For compatibility with older compilers, we obviously want a

#if [understands asm inline]
#define asm_inline asm inline
#else
#define asm_inline asm
#endif

But since we #define the identifier inline to attach some attributes,
we have to use an alternate spelling of that keyword. gcc provides
both __inline__ and __inline, and we currently #define both to inline,
so they all have the same semantics.

We have to free up one of __inline__ and __inline, and the latter is
by far the easiest.

The two x86 changes cause smaller code gen differences than I'd
expect, but I think we do want the asm_inline thing available sooner
or later, so this is just to get the ball rolling"

* tag 'compiler-attributes-for-linus-v5.4' of git://github.com/ojeda/linux:
x86: bug.h: use asm_inline in _BUG_FLAGS definitions
x86: alternative.h: use asm_inline for all alternative variants
compiler-types.h: add asm_inline definition
compiler_types.h: don't #define __inline
lib/zstd/mem.h: replace __inline by inline
staging: rtl8723bs: replace __inline by inline

+29 -11
+7 -7
arch/x86/include/asm/alternative.h
··· 201 201 * without volatile and memory clobber. 202 202 */ 203 203 #define alternative(oldinstr, newinstr, feature) \ 204 - asm volatile (ALTERNATIVE(oldinstr, newinstr, feature) : : : "memory") 204 + asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, feature) : : : "memory") 205 205 206 206 #define alternative_2(oldinstr, newinstr1, feature1, newinstr2, feature2) \ 207 - asm volatile(ALTERNATIVE_2(oldinstr, newinstr1, feature1, newinstr2, feature2) ::: "memory") 207 + asm_inline volatile(ALTERNATIVE_2(oldinstr, newinstr1, feature1, newinstr2, feature2) ::: "memory") 208 208 209 209 /* 210 210 * Alternative inline assembly with input. ··· 218 218 * Leaving an unused argument 0 to keep API compatibility. 219 219 */ 220 220 #define alternative_input(oldinstr, newinstr, feature, input...) \ 221 - asm volatile (ALTERNATIVE(oldinstr, newinstr, feature) \ 221 + asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, feature) \ 222 222 : : "i" (0), ## input) 223 223 224 224 /* ··· 231 231 */ 232 232 #define alternative_input_2(oldinstr, newinstr1, feature1, newinstr2, \ 233 233 feature2, input...) \ 234 - asm volatile(ALTERNATIVE_2(oldinstr, newinstr1, feature1, \ 234 + asm_inline volatile(ALTERNATIVE_2(oldinstr, newinstr1, feature1, \ 235 235 newinstr2, feature2) \ 236 236 : : "i" (0), ## input) 237 237 238 238 /* Like alternative_input, but with a single output argument */ 239 239 #define alternative_io(oldinstr, newinstr, feature, output, input...) \ 240 - asm volatile (ALTERNATIVE(oldinstr, newinstr, feature) \ 240 + asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, feature) \ 241 241 : output : "i" (0), ## input) 242 242 243 243 /* Like alternative_io, but for replacing a direct call with another one. */ 244 244 #define alternative_call(oldfunc, newfunc, feature, output, input...) \ 245 - asm volatile (ALTERNATIVE("call %P[old]", "call %P[new]", feature) \ 245 + asm_inline volatile (ALTERNATIVE("call %P[old]", "call %P[new]", feature) \ 246 246 : output : [old] "i" (oldfunc), [new] "i" (newfunc), ## input) 247 247 248 248 /* ··· 253 253 */ 254 254 #define alternative_call_2(oldfunc, newfunc1, feature1, newfunc2, feature2, \ 255 255 output, input...) \ 256 - asm volatile (ALTERNATIVE_2("call %P[old]", "call %P[new1]", feature1,\ 256 + asm_inline volatile (ALTERNATIVE_2("call %P[old]", "call %P[new1]", feature1,\ 257 257 "call %P[new2]", feature2) \ 258 258 : output, ASM_CALL_CONSTRAINT \ 259 259 : [old] "i" (oldfunc), [new1] "i" (newfunc1), \
+2 -2
arch/x86/include/asm/bug.h
··· 32 32 33 33 #define _BUG_FLAGS(ins, flags) \ 34 34 do { \ 35 - asm volatile("1:\t" ins "\n" \ 35 + asm_inline volatile("1:\t" ins "\n" \ 36 36 ".pushsection __bug_table,\"aw\"\n" \ 37 37 "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ 38 38 "\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \ ··· 49 49 50 50 #define _BUG_FLAGS(ins, flags) \ 51 51 do { \ 52 - asm volatile("1:\t" ins "\n" \ 52 + asm_inline volatile("1:\t" ins "\n" \ 53 53 ".pushsection __bug_table,\"aw\"\n" \ 54 54 "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ 55 55 "\t.word %c0" "\t# bug_entry::flags\n" \
+16 -1
include/linux/compiler_types.h
··· 146 146 __inline_maybe_unused notrace 147 147 #endif 148 148 149 + /* 150 + * gcc provides both __inline__ and __inline as alternate spellings of 151 + * the inline keyword, though the latter is undocumented. New kernel 152 + * code should only use the inline spelling, but some existing code 153 + * uses __inline__. Since we #define inline above, to ensure 154 + * __inline__ has the same semantics, we need this #define. 155 + * 156 + * However, the spelling __inline is strictly reserved for referring 157 + * to the bare keyword. 158 + */ 149 159 #define __inline__ inline 150 - #define __inline inline 151 160 152 161 /* 153 162 * GCC does not warn about unused static inline functions for -Wunused-function. ··· 204 195 205 196 #ifndef asm_volatile_goto 206 197 #define asm_volatile_goto(x...) asm goto(x) 198 + #endif 199 + 200 + #ifdef CONFIG_CC_HAS_ASM_INLINE 201 + #define asm_inline asm __inline 202 + #else 203 + #define asm_inline asm 207 204 #endif 208 205 209 206 #ifndef __no_fgcse
+3
init/Kconfig
··· 33 33 config TOOLS_SUPPORT_RELR 34 34 def_bool $(success,env "CC=$(CC)" "LD=$(LD)" "NM=$(NM)" "OBJCOPY=$(OBJCOPY)" $(srctree)/scripts/tools-support-relr.sh) 35 35 36 + config CC_HAS_ASM_INLINE 37 + def_bool $(success,echo 'void foo(void) { asm inline (""); }' | $(CC) -x c - -c -o /dev/null) 38 + 36 39 config CC_HAS_WARN_MAYBE_UNINITIALIZED 37 40 def_bool $(cc-option,-Wmaybe-uninitialized) 38 41 help
+1 -1
lib/zstd/mem.h
··· 27 27 /*-**************************************** 28 28 * Compiler specifics 29 29 ******************************************/ 30 - #define ZSTD_STATIC static __inline __attribute__((unused)) 30 + #define ZSTD_STATIC static inline 31 31 32 32 /*-************************************************************** 33 33 * Basic Types