diff options
author | Chris Lattner <sabre@nondot.org> | 2010-11-17 05:58:54 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-11-17 05:58:54 +0000 |
commit | 47fc7e93b6af9e6a967231133a2f4bc626eeed26 (patch) | |
tree | eb34b422237d0d9432ef2dc80f4535d143b29997 /lib/CodeGen/CGStmt.cpp | |
parent | 6d0a00d9b02499d6c1253ea03d4dc7c32f8f289e (diff) |
factor some code out to a helper function, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119464 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGStmt.cpp')
-rw-r--r-- | lib/CodeGen/CGStmt.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 282541bd02..d8a16fc7d7 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -948,6 +948,15 @@ llvm::Value* CodeGenFunction::EmitAsmInput(const AsmStmt &S, 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 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { // 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; |