[PATCH] D97449: [Diagnose] Unify MCContext and LLVMContext diagnosing

David Spickett via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 11 06:59:06 PDT 2021


DavidSpickett added a comment.

@ychen Since this change the warning emitted in `AsmPrinterInlineAsm.cpp` about reserved registers no longer has location information for the file that the inline asm is in. Here's an example:

  void bar(void)
  {
      __asm__ __volatile__ ( "nop" : : : "sp");
  }
  
  ./bin/clang --target=arm-arm-none-eabi -march=armv7-m -c /tmp/test.c -o /dev/null

Before:

  /tmp/test.c:3:28: warning: inline asm clobber list contains reserved registers: SP [-Winline-asm]
      __asm__ __volatile__ ( "nop" : : : "sp");
                             ^
  <inline asm>:1:1: note: instantiated into assembly here
          nop
  ^
  /tmp/test.c:3:28: note: Reserved registers on the clobber list may not be preserved across the asm statement, and clobbering them may lead to undefined behaviour.
      __asm__ __volatile__ ( "nop" : : : "sp");
                             ^
  <inline asm>:1:1: note: instantiated into assembly here
          nop
  ^
  1 warning generated.

After:

  <inline asm>:1:1: warning: inline asm clobber list contains reserved registers: SP
          nop
  ^^^^^^^^
  <inline asm>:1:1: note: Reserved registers on the clobber list may not be preserved across the asm statement, and clobbering them may lead to undefined behaviour.
          nop
  ^^^^^^^^

(the reason it didn't break any tests is that we only check this message from IR and only look for the "contains reserved registers" line)

Can you guide me on how I might correct this?

My current impression is that since this code does `SrcMgr.PrintMessage(Loc, SourceMgr::DK_Warning, Msg)` it's one level too deep to get source information added to it automatically. And that if this code could use `DK_InlineAsm` that would help. However getting hold of the Diagnostic manager from MCContext isn't possible currently, perhaps that is by design?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97449/new/

https://reviews.llvm.org/D97449



More information about the llvm-commits mailing list