Skip to content

Commit 83e420c

Browse files
committed
[Constant] Inline ConstantInt::getSigned
ConstantInt::getSigned calls ConstantInt::get with the IsSigned flag set to true. That flag normally defaults to false. For always signed constants the code base is not consistent about whether it uses ConstantInt::getSigned or ConstantInt::get with IsSigned set to true. And it's not clear how to decide which way to use. By making getSigned inline, both ways should generate the same code in the end. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D146598
1 parent 8eb464f commit 83e420c

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

llvm/include/llvm/IR/Constants.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,12 @@ class ConstantInt final : public ConstantData {
111111
/// either getSExtValue() or getZExtValue() will yield a correctly sized and
112112
/// signed value for the type Ty.
113113
/// Get a ConstantInt for a specific signed value.
114-
static ConstantInt *getSigned(IntegerType *Ty, int64_t V);
115-
static Constant *getSigned(Type *Ty, int64_t V);
114+
static ConstantInt *getSigned(IntegerType *Ty, int64_t V) {
115+
return get(Ty, V, true);
116+
}
117+
static Constant *getSigned(Type *Ty, int64_t V) {
118+
return get(Ty, V, true);
119+
}
116120

117121
/// Return a ConstantInt with the specified value and an implied Type. The
118122
/// type is the integer type that corresponds to the bit width of the value.

llvm/lib/IR/Constants.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -899,14 +899,6 @@ ConstantInt *ConstantInt::get(IntegerType *Ty, uint64_t V, bool isSigned) {
899899
return get(Ty->getContext(), APInt(Ty->getBitWidth(), V, isSigned));
900900
}
901901

902-
ConstantInt *ConstantInt::getSigned(IntegerType *Ty, int64_t V) {
903-
return get(Ty, V, true);
904-
}
905-
906-
Constant *ConstantInt::getSigned(Type *Ty, int64_t V) {
907-
return get(Ty, V, true);
908-
}
909-
910902
Constant *ConstantInt::get(Type *Ty, const APInt& V) {
911903
ConstantInt *C = get(Ty->getContext(), V);
912904
assert(C->getType() == Ty->getScalarType() &&

0 commit comments

Comments
 (0)