================
@@ -3574,20 +3574,26 @@ ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr(
CGF.EmitIgnoredExpr(E->getArgumentExpr());
}
- auto VlaSize = CGF.getVLASize(VAT);
- llvm::Value *size = VlaSize.NumElts;
-
// For sizeof and __datasizeof, we need to scale the number of elements
// by the size of the array element type. For _Countof, we just want to
// return the size directly.
+ llvm::Value *Size;
if (Kind != UETT_CountOf) {
+ auto VlaSize = CGF.getVLASize(VAT);
+ Size = VlaSize.NumElts;
+
// Scale the number of non-VLA elements by the non-VLA element size.
CharUnits eltSize =
CGF.getContext().getTypeSizeInChars(VlaSize.Type);
if (!eltSize.isOne())
- size = CGF.Builder.CreateNUWMul(CGF.CGM.getSize(eltSize), size);
+ Size = CGF.Builder.CreateNUWMul(CGF.CGM.getSize(eltSize), Size);
----------------
erichkeane wrote:
I find myself wondering whether 'early return 'would make this all easier.
Also, I would expect the builder's constant folder to make the `eltSize ==1`
case a no-op anyway, so we might just be able to make this whole branch:
return CGF.Builder.CreateNUWMul(CGF.CGM.getSize(eltSize), VlaSize.NumElts).
Though, enough of this is pre-existing, *eh*.
https://github.com/llvm/llvm-project/pull/141621
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits