[PATCH] D29413: [Assembler] Add a pointer to the inline assembly SourceMgr in MCContext.

Sanne Wouda via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 1 11:46:04 PST 2017


sanwou01 created this revision.

This allows for proper error messages through the inline assembly
SourceMgr.  The AsmPrinter's life time includes the MCContext's life
time.


https://reviews.llvm.org/D29413

Files:
  include/llvm/MC/MCContext.h
  lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp


Index: lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -95,6 +95,8 @@
   SourceMgr &SrcMgr = *getInlineSourceManager();
   SrcMgr.setIncludeDirs(MCOptions.IASSearchPaths);
 
+  MCContext &Context = MMI->getContext();
+  Context.setInlineSourceManager(&SrcMgr);
 
   // If the current LLVMContext has an inline asm handler, set it in SourceMgr.
   LLVMContext &LLVMCtx = MMI->getModule()->getContext();
Index: include/llvm/MC/MCContext.h
===================================================================
--- include/llvm/MC/MCContext.h
+++ include/llvm/MC/MCContext.h
@@ -59,6 +59,9 @@
     /// The SourceMgr for this object, if any.
     const SourceMgr *SrcMgr;
 
+    /// The SourceMgr for inline assembly, if any.
+    SourceMgr *InlineSrcMgr;
+
     /// The MCAsmInfo for this target.
     const MCAsmInfo *MAI;
 
@@ -240,6 +243,8 @@
 
     const SourceMgr *getSourceManager() const { return SrcMgr; }
 
+    void setInlineSourceManager(SourceMgr *SM) { InlineSrcMgr = SM; }
+
     const MCAsmInfo *getAsmInfo() const { return MAI; }
 
     const MCRegisterInfo *getRegisterInfo() const { return MRI; }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29413.86691.patch
Type: text/x-patch
Size: 1281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170201/b08c08bb/attachment.bin>


More information about the llvm-commits mailing list