[PATCH] Machine Level IR Serialization: print and parse LLVM IR.

Alex L arphaman at gmail.com
Thu May 21 11:05:22 PDT 2015


Thanks,

I will commit a YAML Parser change with a testcase and then I will recommit
the reverted MIR commit.

Alex.

2015-05-21 10:59 GMT-07:00 Duncan P. N. Exon Smith <dexonsmith at apple.com>:

>
> > On 2015 May 20, at 14:57, Alex L <arphaman at gmail.com> wrote:
> >
> > I would like to resubmit the reverted commit now that I committed the
> AsmParser change in r237833.
> >
> > I've attached an updated patch and a smaller patch that shows the change
> between the reverted commit and the
> > updated patch.
> >
> > The updated patch adds a terminating null character to the LLVM IR
> sourced that's passed from MIRParser
> > to LLParser.
> >
>
> I don't think you should make a new copy of the string here.  Instead,
> null-terminate the source string when it's created.
>
> Here's the code that creates the source string:
>
>     case Token::TK_BlockScalar: {
>       getNext();
>       StringRef StrCopy = StringRef(T.Value).copy(NodeAllocator);
>       return new (NodeAllocator)
>           BlockScalarNode(stream.CurrentDoc, AnchorInfo.Range.substr(1),
>                           TagInfo.Range, StrCopy, T.Range);
>     }
>
> Just change this code to:
>
>     case Token::TK_BlockScalar: {
>       getNext();
>       StringRef NullStr(T.Value.c_str(), T.Value.length() + 1);
>       StringRef StrCopy = NullStr.copy(NodeAllocator).drop_back();
>       return new (NodeAllocator)
>           BlockScalarNode(stream.CurrentDoc, AnchorInfo.Range.substr(1),
>                           TagInfo.Range, StrCopy, T.Range);
>     }
>
> You can commit this ahead of time and write a unit test for it, then
> commit your previously LGTM'ed patch.
>
> (BTW, I used `std::string::c_str()` up above, which has always
> guaranteed a null-terminated string.  Since C++11, `std::string::data()`
> should be identical, but I don't know if all our standard libraries are
> up-to-date.)
>
> > Thanks,
> > Alex
> >
> > 2015-05-19 11:21 GMT-07:00 Alex Lorenz <arphaman at gmail.com>:
> > REPOSITORY
> >   rL LLVM
> >
> > http://reviews.llvm.org/D9616
> >
> > Files:
> >   llvm/trunk/include/llvm/CodeGen/MIR/MIRParser.h
> >   llvm/trunk/include/llvm/CodeGen/Passes.h
> >   llvm/trunk/include/llvm/InitializePasses.h
> >   llvm/trunk/include/llvm/Support/YAMLTraits.h
> >   llvm/trunk/lib/CodeGen/CMakeLists.txt
> >   llvm/trunk/lib/CodeGen/LLVMBuild.txt
> >   llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
> >   llvm/trunk/lib/CodeGen/MIR/CMakeLists.txt
> >   llvm/trunk/lib/CodeGen/MIR/LLVMBuild.txt
> >   llvm/trunk/lib/CodeGen/MIR/MIRParser.cpp
> >   llvm/trunk/lib/CodeGen/MIR/MIRPrinter.cpp
> >   llvm/trunk/lib/CodeGen/MIR/MIRPrinter.h
> >   llvm/trunk/lib/CodeGen/MIR/MIRPrintingPass.cpp
> >   llvm/trunk/lib/CodeGen/MIR/Makefile
> >   llvm/trunk/lib/CodeGen/Makefile
> >   llvm/trunk/lib/Support/YAMLTraits.cpp
> >   llvm/trunk/test/CodeGen/Generic/stop-after.ll
> >   llvm/trunk/test/CodeGen/MIR/lit.local.cfg
> >   llvm/trunk/test/CodeGen/MIR/llvmIR.mir
> >   llvm/trunk/test/CodeGen/MIR/llvmIRMissing.mir
> >   llvm/trunk/tools/llc/llc.cpp
> >
> > EMAIL PREFERENCES
> >   http://reviews.llvm.org/settings/panel/emailpreferences/
> >
> > <MIR.patch><MIR_Revert_vs_Update.patch>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150521/bc859e2b/attachment.html>


More information about the llvm-commits mailing list