<div class="gmail_quote">On Mon, Aug 13, 2012 at 1:32 PM, Chad Rosier <span dir="ltr"><<a href="mailto:mcrosier@apple.com" target="_blank">mcrosier@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: mcrosier<br>
Date: Mon Aug 13 15:32:07 2012<br>
New Revision: 161780<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=161780&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=161780&view=rev</a><br>
Log:<br>
[ms-inline asm] Have patchMSAsmStrings() return a vector or AsmStrings.<br>
<br>
The AsmParser expects a single asm instruction, but valid ms-style inline asm<br>
statements may contain multiple instructions.<br>
<br>
This happens with asm blocks<br>
<br>
__asm {<br>
mov ebx, eax<br>
mov ecx, ebx<br>
}<br>
<br>
or when multiple asm statements are adjacent to one another<br>
<br>
__asm mov ebx, eax<br>
__asm mov ecx, ebx<br>
<br>
and<br>
<br>
__asm mov ebx, eax __asm mov ecx, ebx<br>
<br>
Currently, asm blocks are not properly handled.<br>
<br>
Modified:<br>
cfe/trunk/lib/Sema/SemaStmt.cpp<br>
cfe/trunk/test/CodeGen/ms-inline-asm.c<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=161780&r1=161779&r2=161780&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=161780&r1=161779&r2=161780&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Mon Aug 13 15:32:07 2012<br>@@ -2921,29 +2935,32 @@<br>
const std::string &TT = Context.getTargetInfo().getTriple().getTriple();<br>
const llvm::Target *TheTarget(llvm::TargetRegistry::lookupTarget(TT, Error));<br>
<br>
- llvm::SourceMgr SrcMgr;<br>
- llvm::MemoryBuffer *Buffer =<br>
- llvm::MemoryBuffer::getMemBuffer(PatchedAsmString, "<inline asm>");<br>
-<br>
- // Tell SrcMgr about this buffer, which is what the parser will pick up.<br>
- SrcMgr.AddNewSourceBuffer(Buffer, llvm::SMLoc());<br>
-<br>
OwningPtr<llvm::MCAsmInfo> MAI(TheTarget->createMCAsmInfo(TT));<br>
OwningPtr<llvm::MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TT));<br>
OwningPtr<llvm::MCObjectFileInfo> MOFI(new llvm::MCObjectFileInfo());<br>
- llvm::MCContext Ctx(*MAI, *MRI, MOFI.get(), &SrcMgr);<br>
OwningPtr<llvm::MCSubtargetInfo><br>
STI(TheTarget->createMCSubtargetInfo(TT, "", ""));<br>
<br>
- OwningPtr<llvm::MCStreamer> Str;<br>
- OwningPtr<llvm::MCAsmParser><br>
- Parser(createMCAsmParser(SrcMgr, Ctx, *Str.get(), *MAI));<br>
- OwningPtr<llvm::MCTargetAsmParser><br>
- TargetParser(TheTarget->createMCAsmParser(*STI, *Parser));<br>
-<br>
- // Change to the Intel dialect.<br>
- Parser->setAssemblerDialect(1);<br>
- Parser->setTargetParser(*TargetParser.get());<br>
+ for (unsigned i = 0, e = PatchedAsmStrings.size(); i != e; ++i) {<br>
+ llvm::SourceMgr SrcMgr;<br>
+ llvm::MCContext Ctx(*MAI, *MRI, MOFI.get(), &SrcMgr);<br>
+ llvm::MemoryBuffer *Buffer =<br>
+ llvm::MemoryBuffer::getMemBuffer(PatchedAsmStrings[i], "<inline asm>");<br>
+<br>
+ // Tell SrcMgr about this buffer, which is what the parser will pick up.<br>
+ SrcMgr.AddNewSourceBuffer(Buffer, llvm::SMLoc());<br>
+<br>
+ OwningPtr<llvm::MCStreamer> Str;<br>
+ OwningPtr<llvm::MCAsmParser><br>
+ Parser(createMCAsmParser(SrcMgr, Ctx, *Str.get(), *MAI));<br></blockquote><div><br></div><div>Str.get() is a null pointer here.</div></div>