diff options
author | Sanne Wouda <sanne.wouda@arm.com> | 2017-02-08 10:20:07 +0000 |
---|---|---|
committer | Sanne Wouda <sanne.wouda@arm.com> | 2017-02-08 10:20:07 +0000 |
commit | 09adc245ea90fdc3d484902efec89ea85a27226f (patch) | |
tree | 6faf64039fc9a820c053cedda7bc540f4d667f43 /llvm/test/Assembler | |
parent | 4e01c3e8cdf6ef001de1332ae17384fdd6f20e7d (diff) | |
download | bcm5719-llvm-09adc245ea90fdc3d484902efec89ea85a27226f.tar.gz bcm5719-llvm-09adc245ea90fdc3d484902efec89ea85a27226f.zip |
[Assembler] Enable nicer diagnostics for inline assembly.
Summary:
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.
Reviewers: rnk, grosbach, compnerd, rengolin, rovka, anemet
Reviewed By: rnk
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D29441
llvm-svn: 294433
Diffstat (limited to 'llvm/test/Assembler')
-rw-r--r-- | llvm/test/Assembler/inline-asm-diags.ll | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/test/Assembler/inline-asm-diags.ll b/llvm/test/Assembler/inline-asm-diags.ll new file mode 100644 index 00000000000..070c820b39b --- /dev/null +++ b/llvm/test/Assembler/inline-asm-diags.ll @@ -0,0 +1,9 @@ +; RUN: not llc -filetype=obj < %s 2>&1 -o /dev/null | FileCheck %s + +module asm ".word 0x10" +module asm ".word -bar" + +; CHECK: <inline asm>:2:7: error: expected relocatable expression + +module asm ".word -foo" +; CHECK: <inline asm>:3:7: error: expected relocatable expression |