[lld] r192311 - Do not process .objtxt file twice.
Rui Ueyama
ruiu at google.com
Wed Oct 9 11:46:28 PDT 2013
On Wed, Oct 9, 2013 at 11:40 AM, Shankar Easwaran
<shankare at codeaurora.org>wrote:
> Hi Ruiu,
>
> I am not ok with the interface. Its difficult to handle things if you want
> to figure out the FileNode type later.
>
> I think readFile should be renamed to getBuffer() which just returns the
> buffer associated with the file (or) an error code.
>
That would improve the code quality. I just consolidated the duplicate code
that you wrote into one place, so I believe it's at least improving. :)
> Darwin needs to do that to get the filetype in the Driver to construct the
> InputGraph nodes properly.
>
I didn't change the behavior of the code.
> Thanks
>
> Shankar Easwaran
>
>
> On 10/9/2013 1:14 PM, Rui Ueyama wrote:
>
>> Author: ruiu
>> Date: Wed Oct 9 13:14:23 2013
>> New Revision: 192311
>>
>> URL: http://llvm.org/viewvc/llvm-**project?rev=192311&view=rev<http://llvm.org/viewvc/llvm-project?rev=192311&view=rev>
>> Log:
>> Do not process .objtxt file twice.
>>
>> A file with .objtxt extension is parsed in readFile(), but because we did
>> not
>> propagate that information to the calling side, calling side would try to
>> parse
>> it again. This patch will fix the issue by adding an extra parameter to
>> readFile().
>>
>> Modified:
>> lld/trunk/include/lld/Driver/**DarwinInputGraph.h
>> lld/trunk/include/lld/Driver/**GnuLdInputGraph.h
>> lld/trunk/include/lld/Driver/**InputGraph.h
>> lld/trunk/include/lld/Driver/**WinLinkInputGraph.h
>> lld/trunk/lib/Driver/**InputGraph.cpp
>>
>> Modified: lld/trunk/include/lld/Driver/**DarwinInputGraph.h
>> URL: http://llvm.org/viewvc/llvm-**project/lld/trunk/include/lld/**
>> Driver/DarwinInputGraph.h?rev=**192311&r1=192310&r2=192311&**view=diff<http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/DarwinInputGraph.h?rev=192311&r1=192310&r2=192311&view=diff>
>> ==============================**==============================**
>> ==================
>> --- lld/trunk/include/lld/Driver/**DarwinInputGraph.h (original)
>> +++ lld/trunk/include/lld/Driver/**DarwinInputGraph.h Wed Oct 9
>> 13:14:23 2013
>> @@ -42,7 +42,9 @@ public:
>> /// \brief Parse the input file to lld::File.
>> llvm::error_code parse(const LinkingContext &ctx, raw_ostream
>> &diagnostics) {
>> - if (error_code ec = readFile(ctx, diagnostics))
>> + // Read the file to _buffer.
>> + bool isYaml = false;
>> + if (error_code ec = readFile(ctx, diagnostics, isYaml))
>> return ec;
>> (void) (_isWholeArchive);
>> return llvm::error_code::success();
>>
>> Modified: lld/trunk/include/lld/Driver/**GnuLdInputGraph.h
>> URL: http://llvm.org/viewvc/llvm-**project/lld/trunk/include/lld/**
>> Driver/GnuLdInputGraph.h?rev=**192311&r1=192310&r2=192311&**view=diff<http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/GnuLdInputGraph.h?rev=192311&r1=192310&r2=192311&view=diff>
>> ==============================**==============================**
>> ==================
>> --- lld/trunk/include/lld/Driver/**GnuLdInputGraph.h (original)
>> +++ lld/trunk/include/lld/Driver/**GnuLdInputGraph.h Wed Oct 9 13:14:23
>> 2013
>> @@ -73,8 +73,11 @@ public:
>> /// \brief Parse the input file to lld::File.
>> llvm::error_code parse(const LinkingContext &ctx, raw_ostream
>> &diagnostics) {
>> // Read the file to _buffer.
>> - if (error_code ec = readFile(ctx, diagnostics))
>> + bool isYaml = false;
>> + if (error_code ec = readFile(ctx, diagnostics, isYaml))
>> return ec;
>> + if (isYaml)
>> + return error_code::success();
>> // Identify File type
>> llvm::sys::fs::file_magic FileType =
>>
>> Modified: lld/trunk/include/lld/Driver/**InputGraph.h
>> URL: http://llvm.org/viewvc/llvm-**project/lld/trunk/include/lld/**
>> Driver/InputGraph.h?rev=**192311&r1=192310&r2=192311&**view=diff<http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/InputGraph.h?rev=192311&r1=192310&r2=192311&view=diff>
>> ==============================**==============================**
>> ==================
>> --- lld/trunk/include/lld/Driver/**InputGraph.h (original)
>> +++ lld/trunk/include/lld/Driver/**InputGraph.h Wed Oct 9 13:14:23 2013
>> @@ -309,7 +309,8 @@ public:
>> protected:
>> /// \brief Read the file into _buffer.
>> - error_code readFile(const LinkingContext &ctx, raw_ostream
>> &diagnostics);
>> + error_code readFile(const LinkingContext &ctx, raw_ostream
>> &diagnostics,
>> + bool &isYaml);
>> StringRef _path; // The path of the
>> Input file
>> InputGraph::FileVectorT _files; // A vector of lld File
>> objects
>>
>> Modified: lld/trunk/include/lld/Driver/**WinLinkInputGraph.h
>> URL: http://llvm.org/viewvc/llvm-**project/lld/trunk/include/lld/**
>> Driver/WinLinkInputGraph.h?**rev=192311&r1=192310&r2=**192311&view=diff<http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/WinLinkInputGraph.h?rev=192311&r1=192310&r2=192311&view=diff>
>> ==============================**==============================**
>> ==================
>> --- lld/trunk/include/lld/Driver/**WinLinkInputGraph.h (original)
>> +++ lld/trunk/include/lld/Driver/**WinLinkInputGraph.h Wed Oct 9
>> 13:14:23 2013
>> @@ -40,8 +40,11 @@ public:
>> /// \brief Parse the input file to lld::File.
>> error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics)
>> {
>> // Read the file to _buffer.
>> - if (error_code ec = readFile(ctx, diagnostics))
>> + bool isYaml = false;
>> + if (error_code ec = readFile(ctx, diagnostics, isYaml))
>> return ec;
>> + if (isYaml)
>> + return error_code::success();
>> llvm::sys::fs::file_magic FileType =
>> llvm::sys::fs::identify_magic(**_buffer->getBuffer());
>>
>> Modified: lld/trunk/lib/Driver/**InputGraph.cpp
>> URL: http://llvm.org/viewvc/llvm-**project/lld/trunk/lib/Driver/**
>> InputGraph.cpp?rev=192311&r1=**192310&r2=192311&view=diff<http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/InputGraph.cpp?rev=192311&r1=192310&r2=192311&view=diff>
>> ==============================**==============================**
>> ==================
>> --- lld/trunk/lib/Driver/**InputGraph.cpp (original)
>> +++ lld/trunk/lib/Driver/**InputGraph.cpp Wed Oct 9 13:14:23 2013
>> @@ -99,7 +99,8 @@ FileNode::FileNode(StringRef path, int64
>> /// \brief Read the file into _buffer.
>> error_code
>> -FileNode::readFile(const LinkingContext &ctx, raw_ostream &diagnostics) {
>> +FileNode::readFile(const LinkingContext &ctx, raw_ostream &diagnostics,
>> + bool &isYaml) {
>> ErrorOr<StringRef> filePath = getPath(ctx);
>> if (!filePath &&
>> error_code(filePath) == llvm::errc::no_such_file_or_**directory)
>> @@ -119,9 +120,11 @@ FileNode::readFile(const LinkingContext
>> // YAML file is identified by a .objtxt extension
>> // FIXME : Identify YAML files by using a magic
>> - if (filePath->endswith(".objtxt")**)
>> + if (filePath->endswith(".objtxt")**) {
>> if (error_code ec = ctx.getYAMLReader().parseFile(**_buffer,
>> _files))
>> return ec;
>> + isYaml = true;
>> + }
>> return error_code::success();
>> }
>>
>>
>> ______________________________**_________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/**mailman/listinfo/llvm-commits<http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>
>>
>>
>>
>
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted
> by the Linux Foundation
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131009/64a9a94d/attachment.html>
More information about the llvm-commits
mailing list