[PATCH] D36876: [IRGen] Evaluate constant static variables referenced through member expressions

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 22 20:58:57 PDT 2017


rjmccall added inline comments.


================
Comment at: lib/CodeGen/CGExprComplex.cpp:163
+        else
+          CGF.EmitLValue(ME->getBase());
+        return *Constant;
----------------
rjmccall wrote:
> There's an EmitIgnoredExpr you could use.
> 
> Also, I think it would be fine to add a generic tryEmitMemberExprAsConstant that takes a MemberExpr and does this DRE stuff behind the scenes; it's not at all different for the different emitters.
Well, actually, now I see why it's different for the complex emitter, but I think you could probably extract out a function that forms a complex pair from a constant output without too much trouble.

Also, as long as you're working with this, I think it's likely that the Agg emitter needs to handle this, too.  I'm not sure I accept the claim there that constant r-value emission never applies to aggregates, but at the very least you need to handle references just as the DRE case does.


Repository:
  rL LLVM

https://reviews.llvm.org/D36876





More information about the cfe-commits mailing list