Re: [RFC 6/8] x86_64/bug: Implement __WARN_printf()

Peter Zijlstra
2025-06-02T21:57:29Z

On Mon, Jun 02, 2025 at 09:38:09AM -0700, Linus Torvalds wrote:

> And no, I'm not ok with only using 'objdump' and friends to look at
> assembly generation. I want to be able to do
>
> make xyz.s
>
> and look at code generation without throwing up.

So if I stuff the asm macro in a global asm() block then GCC ends up
looking like so:

.set warn_imm, 0
warn_add_reg var=warn_imm reg=%rcx # tmp215
.set warn_imm, (warn_imm << 4)
warn_add_reg var=warn_imm reg=%rdx # tmp212
1: ud1 warn_imm(%ecx),%rax # tmp210
.pushsection .discard.annotate_insn,"M",@progbits,8
.long 1b - .
.long 8
.popsection
.pushsection __bug_table, "aw" ; 123: .long 1b - . ; .long .LC76 - . ; .long .LC0 - . ; .word 8710 ; .word 2321 ; .org 123b + 6 + 4 + 6 ; .popsection #,,,

However, clangd is 'helpful' and fully expands the asm macro for the .s
file :-(