[PATCH] [MC] bundle alignment: prevent padding instructions from crossing bundle boundaries

Derek Schuff dschuff at google.com
Wed Jan 30 16:36:30 PST 2013


Updated comments with bonus ASCII art!

Also updated the autogen bundling test and generator, PTAL

On Wed, Jan 30, 2013 at 3:08 PM, Derek Schuff <dschuff at google.com> wrote:
> Typos fixed, and unnecessary comment removed.
>
> On Wed, Jan 30, 2013 at 2:47 PM, Eli Bendersky <eliben at google.com> wrote:
>> +    unsigned TotalLength = static_cast<unsigned>(FragmentSize) + BundlePadding;
>> +    if (F.alignToBundleEnd() && TotalLength > Asm.getBundleAlignSize()) {
>> +      // If the padding itself crosses a bundle boundary, it must be emitted
>> +      // in 2 pieces, since even nop instructions must not cross boundaries.
>> +      unsigned DistanceToBoundary = TotalLength - Asm.getBundleAlignSize();
>>
>> Are you sure it shouldn't be: Asm.getBundleAlignSize() - FragmentSize ?
>
> BundleAlignSize - FragmentSize is the distance from the beginning of
> the next bundle to the beginning of the current fragment. We want the
> distance from the end of the last fragment to the beginning of the
> next bundle.
>
> In other words: (end of last fragment) + TotalLength = (end of current
> fragment),
> (end of last fragment) + DistanceToBoundary + (distance from boundary
> to beginning of current fragment) + FragmentSize = (end of current
> fragment) = (end of next bundle)
> and
> TotalLength = FragmentSize + BundlePadding = BundleAlignSize +
> DistanceToBoundary
>
> I don't know if that way of putting it is any clearer, but I think it's correct.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-nop-boundary2.diff
Type: application/octet-stream
Size: 21997 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130130/c0ec4b7a/attachment.obj>


More information about the llvm-commits mailing list