[PATCH] D29412: [Assembler] Always copy temp inline assembly string.

Sanne Wouda via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 1 11:44:34 PST 2017


sanwou01 created this revision.

This ensures that string (which was previously kept on the stack) is
still alive during finalization.


https://reviews.llvm.org/D29412

Files:
  lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp


Index: lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -111,10 +111,9 @@
   }
 
   std::unique_ptr<MemoryBuffer> Buffer;
-  if (isNullTerminated)
-    Buffer = MemoryBuffer::getMemBuffer(Str, "<inline asm>");
-  else
-    Buffer = MemoryBuffer::getMemBufferCopy(Str, "<inline asm>");
+  // Always copy the inline assembly string into the memory buffer to preserve
+  // it until after finalization.
+  Buffer = MemoryBuffer::getMemBufferCopy(Str, "<inline asm>");
 
   // Tell SrcMgr about this buffer, it takes ownership of the buffer.
   unsigned BufNum = SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29412.86690.patch
Type: text/x-patch
Size: 785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170201/fbead22a/attachment.bin>


More information about the llvm-commits mailing list