[llvm-dev] Performance of large llvm::ConstantDataArrays

Pete Cooper via llvm-dev llvm-dev at lists.llvm.org
Wed Sep 13 21:14:32 PDT 2017


> On Sep 13, 2017, at 12:25 PM, Chris Lovett via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Well I have a great test case if someone wants to help show me where/how to fix this in MC.  
Hi Chris

Looks like its probably almost all there.  In AsmPrinter.cpp emitGlobalConstantDataSequential we do:

if (CDS->isString())
    return AP.OutStreamer->EmitBytes(CDS->getAsString());

After that, either all the time, or perhaps if the array isn’t a small number of integers/floats, you can emit it as a byte sequence with:

	AP.OutStreamer->EmitBinaryData(CDS->getAsString());

Cheers,
Pete
> 
> On Mon, Sep 11, 2017 at 8:24 PM, Chris Lattner <clattner at nondot.org <mailto:clattner at nondot.org>> wrote:
> On Sep 10, 2017, at 1:34 AM, Sean Silva <chisophugis at gmail.com <mailto:chisophugis at gmail.com>> wrote:
>> 
>> IMO, there is a relatively easy solution for this.  Introduce a new subclass of ConstantData which represents a blob of data that gets emitted to the .o file, stored in a reasonable native format.  I think it would be fine to limit this to only representing arrays of primitive types (e.g. array of float, array of bytes, etc) since this keeps the API to the type simple (the type models an array, so it should have array element members only), and things that want to get the elements of the array out can have them returned as ConstantInt’s (or whatever).  I’d name this something like “ConstantArrayBlob”.
>> 
>> 
>> What's the relationship between ConstantDataArray and ConstantArray?
> 
> Ah, it looks like ConstantDataArray is exactly what I was advocating for.  Does Clang generate it from an array of doubles?  Maybe that is all that is missing.
> 
>> densely packed data, instead of as Value*'s." so I assumed that it was a dense representation and it seemed reasonable that an i8 typed one of them would basically operate as a "ConstantArrayBlob". (but I guess if MC still creates one fragment per element that will still be a memory hog regardless of the IR's representation)
> 
> Yeah, MC should totally be fixed.  That’s crazy!
> 
> -Chris
> 
> 
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170913/e84bcc87/attachment-0001.html>


More information about the llvm-dev mailing list