[llvm-commits] [dragonegg] r148538 - in /dragonegg/trunk/src: Backend.cpp Convert.cpp
Duncan Sands
baldrick at free.fr
Fri Jan 20 03:55:19 PST 2012
Author: baldrick
Date: Fri Jan 20 05:55:19 2012
New Revision: 148538
URL: http://llvm.org/viewvc/llvm-project?rev=148538&view=rev
Log:
Print the file and line number when a wrong inline asm is detected.
Modified:
dragonegg/trunk/src/Backend.cpp
dragonegg/trunk/src/Convert.cpp
Modified: dragonegg/trunk/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=148538&r1=148537&r2=148538&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Fri Jan 20 05:55:19 2012
@@ -41,6 +41,7 @@
#include "llvm/CodeGen/RegAllocRegistry.h"
#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetLibraryInfo.h"
@@ -1712,6 +1713,20 @@
emit_alias(p->decl, p->target);
}
+static void InlineAsmDiagnosticHandler(const SMDiagnostic &D, void * /*Data*/,
+ location_t loc) {
+ const char *Message = D.getMessage().c_str();
+ switch (D.getKind()) {
+ case SourceMgr::DK_Error:
+ error_at(loc, "%s", Message);
+ break;
+ case SourceMgr::DK_Warning:
+ case SourceMgr::DK_Note:
+ warning_at(loc, 0, "%s", Message);
+ break;
+ }
+}
+
/// llvm_finish_unit - Finish the .s file. This is called by GCC once the
/// compilation unit has been completely processed.
static void llvm_finish_unit(void * /*gcc_data*/, void * /*user_data*/) {
@@ -1806,12 +1821,21 @@
// Run the code generator, if present.
if (CodeGenPasses) {
+ // Arrange for inline asm problems to be printed nicely.
+ LLVMContext &Context = TheModule->getContext();
+ LLVMContext::InlineAsmDiagHandlerTy OldHandler =
+ Context.getInlineAsmDiagnosticHandler();
+ void *OldHandlerData = Context.getInlineAsmDiagnosticContext();
+ Context.setInlineAsmDiagnosticHandler(InlineAsmDiagnosticHandler, 0);
+
CodeGenPasses->doInitialization();
for (Module::iterator I = TheModule->begin(), E = TheModule->end();
I != E; ++I)
if (!I->isDeclaration())
CodeGenPasses->run(*I);
CodeGenPasses->doFinalization();
+
+ Context.setInlineAsmDiagnosticHandler(OldHandler, OldHandlerData);
}
FormattedOutStream.flush();
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=148538&r1=148537&r2=148538&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Fri Jan 20 05:55:19 2012
@@ -7546,6 +7546,11 @@
CallInst *CV = Builder.CreateCall(Asm, CallOps,
CallResultTypes.empty() ? "" : "asmtmp");
CV->setDoesNotThrow();
+ if (gimple_has_location(stmt)) {
+ // Pass the location of the asm using a !srcloc metadata.
+ Constant *LocationCookie = Builder.getInt64(gimple_location(stmt));
+ CV->setMetadata("srcloc", MDNode::get(Context, LocationCookie));
+ }
// If the call produces a value, store it into the destination.
for (unsigned i = 0, NumResults = CallResultTypes.size(); i != NumResults;
More information about the llvm-commits
mailing list