compiler.h: Fix annotation macro misplacement with Clang

When building with Clang and CONFIG_TRACE_BRANCH_PROFILING, there are a
lot of unreachable warnings, like:

arch/x86/kernel/traps.o: warning: objtool: handle_xfd_event()+0x134: unreachable instruction

Without an input to the inline asm, 'volatile' is ignored for some
reason and Clang feels free to move the reachable() annotation away from
its intended location.

Fix that by re-adding the counter value to the inputs.

Fixes: f1069a8756b9 ("compiler.h: Avoid using inline asm operand modifiers")
Fixes: c199f64ff93c ("instrumentation.h: Avoid using inline asm operand modifiers")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/0417e96909b97a406323409210de7bf13df0b170.1636410380.git.jpoimboe@redhat.com
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Miroslav Benes <mbenes@suse.cz>

Changed files
+4 -4
include
+2 -2
include/linux/compiler.h
··· 121 121 asm volatile(__stringify_label(c) ":\n\t" \ 122 122 ".pushsection .discard.reachable\n\t" \ 123 123 ".long " __stringify_label(c) "b - .\n\t" \ 124 - ".popsection\n\t"); \ 124 + ".popsection\n\t" : : "i" (c)); \ 125 125 }) 126 126 #define annotate_reachable() __annotate_reachable(__COUNTER__) 127 127 ··· 129 129 asm volatile(__stringify_label(c) ":\n\t" \ 130 130 ".pushsection .discard.unreachable\n\t" \ 131 131 ".long " __stringify_label(c) "b - .\n\t" \ 132 - ".popsection\n\t"); \ 132 + ".popsection\n\t" : : "i" (c)); \ 133 133 }) 134 134 #define annotate_unreachable() __annotate_unreachable(__COUNTER__) 135 135
+2 -2
include/linux/instrumentation.h
··· 11 11 asm volatile(__stringify(c) ": nop\n\t" \ 12 12 ".pushsection .discard.instr_begin\n\t" \ 13 13 ".long " __stringify(c) "b - .\n\t" \ 14 - ".popsection\n\t"); \ 14 + ".popsection\n\t" : : "i" (c)); \ 15 15 }) 16 16 #define instrumentation_begin() __instrumentation_begin(__COUNTER__) 17 17 ··· 50 50 asm volatile(__stringify(c) ": nop\n\t" \ 51 51 ".pushsection .discard.instr_end\n\t" \ 52 52 ".long " __stringify(c) "b - .\n\t" \ 53 - ".popsection\n\t"); \ 53 + ".popsection\n\t" : : "i" (c)); \ 54 54 }) 55 55 #define instrumentation_end() __instrumentation_end(__COUNTER__) 56 56 #else