diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-07 05:46:54 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-07 05:46:54 +0000 |
commit | fc1a9c312d249a2c7458f763f848ba42685c23f8 (patch) | |
tree | 895b7ffbfe0f6fbee468c04cbc3a46a759b8cd29 | |
parent | 74626d6ef2e194fcc911e071556660ff331eb4a8 (diff) |
a ridiculous amount of propagation through the backend later,
have the code generate slap a srcloc metadata on inline asm nodes.
This allows us to diagnose invalid inline asms with such nice
diagnostics as:
<inline asm>:1:2: error: unrecognized instruction
abc incl %eax
^
asm.c:2:12: note: generated from here
__asm__ ("abc incl %0" : "+r" (X));
^
2 diagnostics generated.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100608 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGStmt.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index ae2f791719..6604b91db9 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -1044,9 +1044,10 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { // Use ptrtoint as appropriate so that we can do our extension. if (isa<llvm::PointerType>(Arg->getType())) Arg = Builder.CreatePtrToInt(Arg, - llvm::IntegerType::get(VMContext, LLVMPointerWidth)); + llvm::IntegerType::get(VMContext, LLVMPointerWidth)); unsigned OutputSize = (unsigned)getContext().getTypeSize(OutputTy); - Arg = Builder.CreateZExt(Arg, llvm::IntegerType::get(VMContext, OutputSize)); + Arg = Builder.CreateZExt(Arg, + llvm::IntegerType::get(VMContext, OutputSize)); } } @@ -1102,6 +1103,12 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { llvm::CallInst *Result = Builder.CreateCall(IA, Args.begin(), Args.end()); Result->addAttribute(~0, llvm::Attribute::NoUnwind); + // Slap the source location of the inline asm into a !srcloc metadata on the + // call. + unsigned LocID = S.getAsmString()->getLocStart().getRawEncoding(); + llvm::Value *LocIDC = + llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), LocID); + Result->setMetadata("srcloc", llvm::MDNode::get(VMContext, &LocIDC, 1)); // Extract all of the register value results from the asm. std::vector<llvm::Value*> RegResults; |