[PATCH] D87425: [CodeGen][typeid] Emit typeinfo directly if type is known at compile-time

Zequan Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 14 11:27:41 PDT 2020


zequanwu added a comment.

In D87425#2265523 <https://reviews.llvm.org/D87425#2265523>, @hans wrote:

> I'm not sure that changing isPotentiallyEvaluated() is the right thing to do. The meaning of that corresponds to text in the standard: https://eel.is/c++draft/expr.typeid#3 so changing it to something that doesn't match the standard exactly seems wrong.

If the type of the operand is already most derived, we could just emit the typeinfo of the type. This would match the standard: https://eel.is/c++draft/expr.typeid#2

> I think it would be safer to do the change purely as an optimization in codegen (maybe we could add a new helper method that could also be used by the warning).

For "optimization in codegen", do you mean optimization after the IR is generated or like I did in `CodeGenFunction::EmitCXXTypeidExpr`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87425



More information about the cfe-commits mailing list