Skip to content

Commit dcce50e

Browse files
committed
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: f1069a8 ("compiler.h: Avoid using inline asm operand modifiers") Fixes: c199f64 ("instrumentation.h: Avoid using inline asm operand modifiers") Reported-by: kernel test robot <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Link: https://lore.kernel.org/r/0417e96909b97a406323409210de7bf13df0b170.1636410380.git.jpoimboe@redhat.com Cc: Peter Zijlstra <[email protected]> Cc: [email protected] Cc: Vasily Gorbik <[email protected]> Cc: Miroslav Benes <[email protected]>
1 parent cb8747b commit dcce50e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

include/linux/compiler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
121121
asm volatile(__stringify_label(c) ":\n\t" \
122122
".pushsection .discard.reachable\n\t" \
123123
".long " __stringify_label(c) "b - .\n\t" \
124-
".popsection\n\t"); \
124+
".popsection\n\t" : : "i" (c)); \
125125
})
126126
#define annotate_reachable() __annotate_reachable(__COUNTER__)
127127

128128
#define __annotate_unreachable(c) ({ \
129129
asm volatile(__stringify_label(c) ":\n\t" \
130130
".pushsection .discard.unreachable\n\t" \
131131
".long " __stringify_label(c) "b - .\n\t" \
132-
".popsection\n\t"); \
132+
".popsection\n\t" : : "i" (c)); \
133133
})
134134
#define annotate_unreachable() __annotate_unreachable(__COUNTER__)
135135

include/linux/instrumentation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
asm volatile(__stringify(c) ": nop\n\t" \
1212
".pushsection .discard.instr_begin\n\t" \
1313
".long " __stringify(c) "b - .\n\t" \
14-
".popsection\n\t"); \
14+
".popsection\n\t" : : "i" (c)); \
1515
})
1616
#define instrumentation_begin() __instrumentation_begin(__COUNTER__)
1717

@@ -50,7 +50,7 @@
5050
asm volatile(__stringify(c) ": nop\n\t" \
5151
".pushsection .discard.instr_end\n\t" \
5252
".long " __stringify(c) "b - .\n\t" \
53-
".popsection\n\t"); \
53+
".popsection\n\t" : : "i" (c)); \
5454
})
5555
#define instrumentation_end() __instrumentation_end(__COUNTER__)
5656
#else

0 commit comments

Comments
 (0)