[cfe-commits] r119464 - /cfe/trunk/lib/CodeGen/CGStmt.cpp
Chris Lattner
sabre at nondot.org
Tue Nov 16 21:58:54 PST 2010
Author: lattner
Date: Tue Nov 16 23:58:54 2010
New Revision: 119464
URL: http://llvm.org/viewvc/llvm-project?rev=119464&view=rev
Log:
factor some code out to a helper function, no functionality change.
Modified:
cfe/trunk/lib/CodeGen/CGStmt.cpp
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=119464&r1=119463&r2=119464&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Nov 16 23:58:54 2010
@@ -948,6 +948,15 @@
return EmitAsmInputLValue(S, Info, Dest, InputExpr->getType(), ConstraintStr);
}
+/// getAsmSrcLocInfo - Return the !srcloc metadata node to attach to an inline
+/// asm call instruction.
+static llvm::MDNode *getAsmSrcLocInfo(const StringLiteral *Str,
+ CodeGenFunction &CGF) {
+ unsigned LocID = Str->getLocStart().getRawEncoding();
+ llvm::Value *LocIDC = llvm::ConstantInt::get(CGF.Int32Ty, LocID);
+ return llvm::MDNode::get(LocIDC->getContext(), &LocIDC, 1);
+}
+
void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
// Analyze the asm string to decompose it into its pieces. We know that Sema
// has already done this, so it is guaranteed to be successful.
@@ -1171,10 +1180,7 @@
// 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(Int32Ty, LocID);
- Result->setMetadata("srcloc", llvm::MDNode::get(VMContext, &LocIDC, 1));
+ Result->setMetadata("srcloc", getAsmSrcLocInfo(S.getAsmString(), *this));
// Extract all of the register value results from the asm.
std::vector<llvm::Value*> RegResults;
More information about the cfe-commits
mailing list