[PATCH] D77939: [MC] Use subclass data for MCExpr to reduce memory usage

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 13 13:35:10 PDT 2020


nikic added inline comments.


================
Comment at: include/llvm/MC/MCExpr.h:57
+  explicit MCExpr(ExprKind Kind, unsigned SubclassData, SMLoc Loc)
+    : Kind(Kind), SubclassData(SubclassData), Loc(Loc) {}
 
----------------
jsji wrote:
> Call setter to validate data instead?
MCExprs are immutable, so I don't think we should add a setter (and we don't have them for other fields either). However, I've added an assertion in the constructor to check that the subclass data fits.


================
Comment at: include/llvm/MC/MCExpr.h:143
+    assert(SizeInBytes <= 8 && "Excessive size");
+    return SizeInBytes | (PrintInHex ? PrintInHexBit : 0);
+  }
----------------
jsji wrote:
> Should we avoid clobberring by `SizeInBytes & SizeInBytesBits` as well?
The assertion here is intended to make sure that clobbering can't happen.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77939/new/

https://reviews.llvm.org/D77939





More information about the llvm-commits mailing list