[llvm] 4b3d940 - [llvm][Type] Return fixed size for scalar types. [NFC]
Francesco Petrogalli via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 27 15:24:23 PDT 2020
Author: Francesco Petrogalli
Date: 2020-03-27T22:23:46Z
New Revision: 4b3d94051ca2cfc43f276c05f0619d22fc7deb87
URL: https://github.com/llvm/llvm-project/commit/4b3d94051ca2cfc43f276c05f0619d22fc7deb87
DIFF: https://github.com/llvm/llvm-project/commit/4b3d94051ca2cfc43f276c05f0619d22fc7deb87.diff
LOG: [llvm][Type] Return fixed size for scalar types. [NFC]
Summary:
It is safe to assume that the TypeSize associated to scalar types has
a fixed size.
This avoids an implicit cast of TypeSize to integer inside
`Type::getScalarSizeInBits()`, as such implicit cast is deprecated.
Reviewers: efriedma, sdesmalen
Reviewed By: efriedma
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D76892
Added:
Modified:
llvm/lib/IR/Type.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp
index e91bc8aa7e70..b288ab00fde3 100644
--- a/llvm/lib/IR/Type.cpp
+++ b/llvm/lib/IR/Type.cpp
@@ -132,7 +132,8 @@ TypeSize Type::getPrimitiveSizeInBits() const {
}
unsigned Type::getScalarSizeInBits() const {
- return getScalarType()->getPrimitiveSizeInBits();
+ // It is safe to assume that the scalar types have a fixed size.
+ return getScalarType()->getPrimitiveSizeInBits().getFixedSize();
}
int Type::getFPMantissaWidth() const {
More information about the llvm-commits
mailing list