Skip to content

Commit

Permalink
[llvm][Support] Add isZero method for TypeSize. [NFC]
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Francesco Petrogalli committed Mar 27, 2020
1 parent a8cc904 commit c66d1f3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions llvm/include/llvm/Support/TypeSize.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/ConstantFolding.cpp
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/AArch64CallLowering.cpp
Expand Up @@ -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()};
Expand Down

0 comments on commit c66d1f3

Please sign in to comment.