[llvm] d7144df - [IR] Remove unused ConstantExpr::getOffsetOf() methods (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 16 02:43:32 PDT 2023
Author: Nikita Popov
Date: 2023-03-16T10:35:11+01:00
New Revision: d7144df63718e8d882f53400b2e54e0ed67c23a4
URL: https://github.com/llvm/llvm-project/commit/d7144df63718e8d882f53400b2e54e0ed67c23a4
DIFF: https://github.com/llvm/llvm-project/commit/d7144df63718e8d882f53400b2e54e0ed67c23a4.diff
LOG: [IR] Remove unused ConstantExpr::getOffsetOf() methods (NFC)
These are not used and should not be used (just like anything that
creates a constant expression only due to lack of DL-awareness).
Added:
Modified:
llvm/include/llvm/IR/Constants.h
llvm/lib/IR/Constants.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h
index 13d5fb218bed..9cc56ecf8e97 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -1027,16 +1027,6 @@ class ConstantExpr : public Constant {
///
static Constant *getSizeOf(Type *Ty);
- /// getOffsetOf constant expr - computes the offset of a struct field in a
- /// target independent way (Note: the return type is an i64).
- ///
- static Constant *getOffsetOf(StructType *STy, unsigned FieldNo);
-
- /// getOffsetOf constant expr - This is a generalized form of getOffsetOf,
- /// which supports any aggregate type, and any Constant index.
- ///
- static Constant *getOffsetOf(Type *Ty, Constant *FieldNo);
-
static Constant *getNeg(Constant *C, bool HasNUW = false,
bool HasNSW = false);
static Constant *getNot(Constant *C);
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 51ad3a12c488..ba68e6be05b5 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -2397,24 +2397,6 @@ Constant *ConstantExpr::getAlignOf(Type* Ty) {
Type::getInt64Ty(Ty->getContext()));
}
-Constant *ConstantExpr::getOffsetOf(StructType* STy, unsigned FieldNo) {
- return getOffsetOf(STy, ConstantInt::get(Type::getInt32Ty(STy->getContext()),
- FieldNo));
-}
-
-Constant *ConstantExpr::getOffsetOf(Type* Ty, Constant *FieldNo) {
- // offsetof is implemented as: (i64) gep (Ty*)null, 0, FieldNo
- // Note that a non-inbounds gep is used, as null isn't within any object.
- Constant *GEPIdx[] = {
- ConstantInt::get(Type::getInt64Ty(Ty->getContext()), 0),
- FieldNo
- };
- Constant *GEP = getGetElementPtr(
- Ty, Constant::getNullValue(PointerType::getUnqual(Ty)), GEPIdx);
- return getPtrToInt(GEP,
- Type::getInt64Ty(Ty->getContext()));
-}
-
Constant *ConstantExpr::getCompare(unsigned short Predicate, Constant *C1,
Constant *C2, bool OnlyIfReduced) {
assert(C1->getType() == C2->getType() && "Op types should be identical!");
More information about the llvm-commits
mailing list