================
@@ -21,6 +21,88 @@
 using namespace clang;
 using namespace clang::CIRGen;
 
+/// Checks whether the given constructor is a valid subject for the
+/// complete-to-base constructor delgation optimization, i.e. emitting the
+/// complete constructor as a simple call to the base constructor.
----------------
andykaylor wrote:

I don't think there's a good case for doing this optimization later. It would 
basically require the optimizer to recognize that two constructors were 
identical and replace the body of one with a call to the other. We could (and 
maybe should) indicate in some way other than the name mangling which 
constructor it is we're emitting, and I guess theoretically we could set a flag 
indicating that the implementations are identical or provide some other means 
for an optimizer to deduce exactly what we're deciding here. I just don't see 
any benefit to that versus handling it here, particularly once we have added 
the support for constructor aliases.

In cases where the base constructor and complete object constructor are 
identical, we will only emit the base object constructor when constructor 
aliases are enabled. When constructor aliases are not enabled, we will emit 
both even in cases where only the complete object constructor is needed, but 
that will be trivially inlined, which is a much easier problem for the 
optimizer to handle.

https://github.com/llvm/llvm-project/pull/143639
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to