summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGStmt.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-07-28 23:12:59 +0000
committerReid Kleckner <reid@kleckner.net>2014-07-28 23:12:59 +0000
commit4db3256aec0b9a82ff436f7180adfa7257d3deec (patch)
tree187024a1fb93b457244c9172f624653c255ebfb1 /clang/lib/CodeGen/CGStmt.cpp
parent54fd4e5fcb5adad4fcb313ee94b4f2c9e4c1e69f (diff)
downloadbcm5719-llvm-4db3256aec0b9a82ff436f7180adfa7257d3deec.tar.gz
bcm5719-llvm-4db3256aec0b9a82ff436f7180adfa7257d3deec.zip
Add a location to MS inline asm blobs
This isn't nearly as elaborate as the GCC inline asm which emits an array of source locations, but it's very, very hard to trigger backend diagnostics in MS inline asm because we parse it up front with good source information, unlike GCC inline asm. Currently I can trigger a "inline assembly requires more registers than available" diagnostic with this code: void foo(); void bar() { __asm pusha __asm call foo __asm popa } However, if I committed that as a test case, I would have to remove it once I fix PR20052. llvm-svn: 214141
Diffstat (limited to 'clang/lib/CodeGen/CGStmt.cpp')
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 62a80a334ef..d75b97ddf6a 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -2023,10 +2023,15 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
llvm::Attribute::NoUnwind);
// Slap the source location of the inline asm into a !srcloc metadata on the
- // call. FIXME: Handle metadata for MS-style inline asms.
- if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(&S))
+ // call.
+ if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(&S)) {
Result->setMetadata("srcloc", getAsmSrcLocInfo(gccAsmStmt->getAsmString(),
*this));
+ } else {
+ // At least put the line number on MS inline asm blobs.
+ auto Loc = llvm::ConstantInt::get(Int32Ty, S.getAsmLoc().getRawEncoding());
+ Result->setMetadata("srcloc", llvm::MDNode::get(getLLVMContext(), Loc));
+ }
// Extract all of the register value results from the asm.
std::vector<llvm::Value*> RegResults;
OpenPOWER on IntegriCloud