[llvm] c66d1f3 - [llvm][Support] Add isZero method for TypeSize. [NFC]

Francesco Petrogalli via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 27 14:04:46 PDT 2020


Author: Francesco Petrogalli
Date: 2020-03-27T21:03:44Z
New Revision: c66d1f38f6f11ee6bafb0a3f2c06f3bbf4413ab2

URL: https://github.com/llvm/llvm-project/commit/c66d1f38f6f11ee6bafb0a3f2c06f3bbf4413ab2
DIFF: https://github.com/llvm/llvm-project/commit/c66d1f38f6f11ee6bafb0a3f2c06f3bbf4413ab2.diff

LOG: [llvm][Support] Add isZero method for TypeSize. [NFC]

Summary:
The method is used where TypeSize is implicitly cast to integer for
being checked against 0.

Reviewers: sdesmalen, efriedma

Reviewed By: sdesmalen, efriedma

Subscribers: efriedma, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D76748

Added: 
    

Modified: 
    llvm/include/llvm/Support/TypeSize.h
    llvm/lib/Analysis/ConstantFolding.cpp
    llvm/lib/Target/AArch64/AArch64CallLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/TypeSize.h b/llvm/include/llvm/Support/TypeSize.h
index f66c043b29fe..35db42336a7a 100644
--- a/llvm/include/llvm/Support/TypeSize.h
+++ b/llvm/include/llvm/Support/TypeSize.h
@@ -149,6 +149,9 @@ class TypeSize {
   // Returns true if the type size is non-zero.
   bool isNonZero() const { return MinSize != 0; }
 
+  // Returns true if the type size is zero.
+  bool isZero() const { return MinSize == 0; }
+
   // Casts to a uint64_t if this is a fixed-width size.
   //
   // This interface is deprecated and will be removed in a future version

diff  --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 87c22b3609a1..0adabf279178 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -363,7 +363,7 @@ Constant *llvm::ConstantFoldLoadThroughBitcast(Constant *C, Type *DestTy,
       Constant *ElemC;
       do {
         ElemC = C->getAggregateElement(Elem++);
-      } while (ElemC && DL.getTypeSizeInBits(ElemC->getType()) == 0);
+      } while (ElemC && DL.getTypeSizeInBits(ElemC->getType()).isZero());
       C = ElemC;
     } else {
       C = C->getAggregateElement(0u);

diff  --git a/llvm/lib/Target/AArch64/AArch64CallLowering.cpp b/llvm/lib/Target/AArch64/AArch64CallLowering.cpp
index 080c1f1364b7..aace22aa59c0 100644
--- a/llvm/lib/Target/AArch64/AArch64CallLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64CallLowering.cpp
@@ -420,7 +420,7 @@ bool AArch64CallLowering::lowerFormalArguments(
   SmallVector<ArgInfo, 8> SplitArgs;
   unsigned i = 0;
   for (auto &Arg : F.args()) {
-    if (DL.getTypeStoreSize(Arg.getType()) == 0)
+    if (DL.getTypeStoreSize(Arg.getType()).isZero())
       continue;
 
     ArgInfo OrigArg{VRegs[i], Arg.getType()};


        


More information about the llvm-commits mailing list