Skip to content

Could Clang/LLVM warn about missing clobber declarations in extended inline asm? #59400

Open
@zmodem

Description

@zmodem

Consider:

int f(int in) {
  int out;

  asm("movl %1, %%eax;"
      "movl %%eax, %0;"
      "movl $42, %%ebx;"
      :"=r"(out)      // output
      :"r"(in)        // input
      :"%eax"         // clobbered register
      );  
  return out;
}

The inline asm block is clobbering EBX without declaring it, which means the function fails to preserve this callee-saved register.

Since this will be processed by llvm's internal assembler, would it be technically possible to emit a warning about the missing clobber?

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerllvm:asmparser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions