[llvm] r262811 - Bitcode reader: Inline readAbbreviatedField in readRecord and move the enclosing loop in each case (NFC)

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 7 08:20:20 PST 2016


With the gold plugin I got a smaller but measurable speedup. Linking
clang with -plugin-opt=disable-output went from 15.99 seconds to 15.85
seconds.

Cheers,
Rafael


On 6 March 2016 at 19:38, Mehdi Amini via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: mehdi_amini
> Date: Sun Mar  6 18:38:09 2016
> New Revision: 262811
>
> URL: http://llvm.org/viewvc/llvm-project?rev=262811&view=rev
> Log:
> Bitcode reader: Inline readAbbreviatedField in readRecord and move the enclosing loop in each case (NFC)
>
> Summary: This make readRecord 20% faster, measured on an LTO build
>
> Reviewers: rafael
>
> Subscribers: llvm-commits
>
> Differential Revision: http://reviews.llvm.org/D17911
>
> From: Mehdi Amini <mehdi.amini at apple.com>
>
> Modified:
>     llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp
>
> Modified: llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp?rev=262811&r1=262810&r2=262811&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp (original)
> +++ llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp Sun Mar  6 18:38:09 2016
> @@ -131,8 +131,25 @@ void BitstreamCursor::skipRecord(unsigne
>        const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i);
>
>        // Read all the elements.
> -      for (; NumElts; --NumElts)
> -        skipAbbreviatedField(*this, EltEnc);
> +      // Decode the value as we are commanded.
> +      switch (EltEnc.getEncoding()) {
> +      default:
> +        report_fatal_error("Array element type can't be an Array or a Blob");
> +      case BitCodeAbbrevOp::Fixed:
> +        assert((unsigned)Op.getEncodingData() <= MaxChunkSize);
> +        for (; NumElts; --NumElts)
> +          Read((unsigned)EltEnc.getEncodingData());
> +        break;
> +      case BitCodeAbbrevOp::VBR:
> +        assert((unsigned)Op.getEncodingData() <= MaxChunkSize);
> +        for (; NumElts; --NumElts)
> +          ReadVBR64((unsigned)EltEnc.getEncodingData());
> +        break;
> +      case BitCodeAbbrevOp::Char6:
> +        for (; NumElts; --NumElts)
> +          Read(6);
> +        break;
> +      }
>        continue;
>      }
>
> @@ -206,13 +223,23 @@ unsigned BitstreamCursor::readRecord(uns
>        if (!EltEnc.isEncoding())
>          report_fatal_error(
>              "Array element type has to be an encoding of a type");
> -      if (EltEnc.getEncoding() == BitCodeAbbrevOp::Array ||
> -          EltEnc.getEncoding() == BitCodeAbbrevOp::Blob)
> -        report_fatal_error("Array element type can't be an Array or a Blob");
>
>        // Read all the elements.
> -      for (; NumElts; --NumElts)
> -        Vals.push_back(readAbbreviatedField(*this, EltEnc));
> +      switch (EltEnc.getEncoding()) {
> +      default:
> +        report_fatal_error("Array element type can't be an Array or a Blob");
> +      case BitCodeAbbrevOp::Fixed:
> +        for (; NumElts; --NumElts)
> +          Vals.push_back(Read((unsigned)EltEnc.getEncodingData()));
> +        break;
> +      case BitCodeAbbrevOp::VBR:
> +        for (; NumElts; --NumElts)
> +          Vals.push_back(ReadVBR64((unsigned)EltEnc.getEncodingData()));
> +        break;
> +      case BitCodeAbbrevOp::Char6:
> +        for (; NumElts; --NumElts)
> +          Vals.push_back(BitCodeAbbrevOp::DecodeChar6(Read(6)));
> +      }
>        continue;
>      }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list