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

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 11 12:15:25 PDT 2020


MaskRay added a comment.

Thanks for the change! It is good. I only got some nits.



================
Comment at: include/llvm/MC/MCExpr.h:333
+                              bool HasSubsectionsViaSymbols) {
+    return ((unsigned) Kind) |
+           (UseParensForSymbolVariant ? UseParensForSymbolVariantBit : 0) |
----------------
Nit: no space after `(unsigned)`. No outer parentheses.

Alternatively, use `static_cast<unsigned>`


================
Comment at: include/llvm/MC/MCExpr.h:365
+  VariantKind getKind() const {
+    return (VariantKind) (getSubclassData() & 0xffff);
+  }
----------------
Nit: no space after `(VariantKind)`.

Alternatively, use `static_cast<VariantKind>`


================
Comment at: include/llvm/MC/MCExpr.h:433
   /// Get the kind of this unary expression.
-  Opcode getOpcode() const { return Op; }
+  Opcode getOpcode() const { return (Opcode) getSubclassData(); }
 
----------------
ditto


================
Comment at: include/llvm/MC/MCExpr.h:589
   /// Get the kind of this binary expression.
-  Opcode getOpcode() const { return Op; }
+  Opcode getOpcode() const { return (Opcode) getSubclassData(); }
 
----------------
ditto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77939





More information about the llvm-commits mailing list