================
@@ -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);
----------------
AaronBallman wrote:

I made the changes; I think it's a bit cleaner now, though I did not remove the 
`isOne()` check because we might as well make the IR slightly smaller so 
compile times are slightly faster. Very, very, VERY slightly. :-D

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

Reply via email to