[PATCH] D29441: [Assembler] Enable nicer diagnostics for inline assembly.

Sanne Wouda via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 2 01:30:55 PST 2017


sanwou01 created this revision.

Enables source location in diagnostic messages from the backend.  This
is after parsing, during finalization.  This requires the SourceMgr, the
inline assembly string buffer, and DiagInfo to still be alive after
EmitInlineAsm returns.

This patch creates a single SourceMgr for inline assembly inside the
AsmPrinter.  MCContext gets a pointer to this SourceMgr.  Using one
SourceMgr per call to EmitInlineAsm would make it difficult for
MCContext to figure out in which SourceMgr the SMLoc is located, while a
single SourceMgr can figure it out if it has multiple buffers.

The Str argument to EmitInlineAsm is copied into a buffer and owned by
the inline asm SourceMgr.  This ensures that DiagHandlers won't print
garbage.  (Clang emits a "note: instantiated into assembly here", which
refers to this string.)

The AsmParser gets destroyed before finalization, which means that the
DiagHandlers the AsmParser installs into the SourceMgr will be stale.
Restore the saved DiagHandlers.

Since now we're using just one SourceMgr for multiple inline asm
strings, we need to tell the AsmParser which buffer it needs to parse
currently.  Hand a buffer id -- returned from SourceMgr::
AddNewSourceBuffer -- to the AsmParser.


https://reviews.llvm.org/D29441

Files:
  include/llvm/CodeGen/AsmPrinter.h
  include/llvm/MC/MCContext.h
  include/llvm/MC/MCParser/MCAsmParser.h
  lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
  lib/MC/MCContext.cpp
  lib/MC/MCParser/AsmParser.cpp
  test/Assembler/inline-asm-diags.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29441.86779.patch
Type: text/x-patch
Size: 8479 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170202/34e1c1c3/attachment.bin>


More information about the llvm-commits mailing list