[llvm-commits] [llvm] r100509 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
Chris Lattner
sabre at nondot.org
Mon Apr 5 17:55:39 PDT 2010
Author: lattner
Date: Mon Apr 5 19:55:39 2010
New Revision: 100509
URL: http://llvm.org/viewvc/llvm-project?rev=100509&view=rev
Log:
report errors through LLVMContext's inline asm handler if available.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp?rev=100509&r1=100508&r2=100509&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp Mon Apr 5 19:55:39 2010
@@ -14,7 +14,10 @@
#define DEBUG_TYPE "asm-printer"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/InlineAsm.h"
+#include "llvm/LLVMContext.h"
+#include "llvm/Module.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
+#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
@@ -49,6 +52,17 @@
}
SourceMgr SrcMgr;
+
+ // If the current LLVMContext has an inline asm handler, set it in SourceMgr.
+ LLVMContext &LLVMCtx = MMI->getModule()->getContext();
+ bool HasDiagHandler = false;
+ if (void *DiagHandler = LLVMCtx.getInlineAsmDiagnosticHandler()) {
+ unsigned Cookie = 0; // no cookie yet.
+ SrcMgr.setDiagHandler((SourceMgr::DiagHandlerTy)(intptr_t)DiagHandler,
+ LLVMCtx.getInlineAsmDiagnosticContext(), Cookie);
+ HasDiagHandler = true;
+ }
+
MemoryBuffer *Buffer;
if (isNullTerminated)
Buffer = MemoryBuffer::getMemBuffer(Str, "<inline asm>");
@@ -68,7 +82,7 @@
// Don't implicitly switch to the text section before the asm.
int Res = Parser.Run(/*NoInitialTextSection*/ true,
/*NoFinalize*/ true);
- if (Res)
+ if (Res && !HasDiagHandler)
llvm_report_error("Error parsing inline asm\n");
}
More information about the llvm-commits
mailing list