================ @@ -149,14 +157,44 @@ class SourceLocationSequence::State { operator SourceLocationSequence *() { return &Seq; } }; -inline uint64_t SourceLocationEncoding::encode(SourceLocation Loc, - SourceLocationSequence *Seq) { - return Seq ? Seq->encode(Loc) : encodeRaw(Loc.getRawEncoding()); +inline SourceLocationEncoding::RawLocEncoding +SourceLocationEncoding::encode(SourceLocation Loc, UIntTy BaseOffset, + unsigned BaseModuleFileIndex, + SourceLocationSequence *Seq) { + // If the source location is a local source location, we can try to optimize + // the similar sequences to only record the differences. + if (!BaseOffset) + return Seq ? Seq->encode(Loc) : encodeRaw(Loc.getRawEncoding()); + + if (Loc.isInvalid()) + return 0; + + // Otherwise, the higher bits are used to store the module file index, + // so it is meaningless to optimize the source locations into small + // integers. Let's try to always use the raw encodings. + assert(Loc.getOffset() >= BaseOffset); + Loc = Loc.getLocWithOffset(-BaseOffset); + RawLocEncoding Encoded = encodeRaw(Loc.getRawEncoding()); + assert(Encoded < ((RawLocEncoding)1 << 32)); ---------------- jansvoboda11 wrote:
My compiler says: ``` warning: result of comparison of constant 4294967296 with expression of type 'unsigned int' is always true [-Wtautological-constant-out-of-range-compare] ``` https://github.com/llvm/llvm-project/pull/86912 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits