diff options
author | Ramkumar Ramachandra <Ramkumar.Ramachandra@imgtec.com> | 2023-07-28 17:18:22 +0100 |
---|---|---|
committer | Ramkumar Ramachandra <Ramkumar.Ramachandra@imgtec.com> | 2023-07-28 17:46:15 +0100 |
commit | aabc71485a2dce11bbad9fbddac66428ddb41ef7 (patch) | |
tree | 0cc930360897b397caa61eb926cc8249d122ced4 /llvm/lib/Analysis/ConstantFolding.cpp | |
parent | 0a5e0d3fad8dfdebc8bb2f51f6008bdd41e27580 (diff) | |
download | llvm-aabc71485a2dce11bbad9fbddac66428ddb41ef7.zip llvm-aabc71485a2dce11bbad9fbddac66428ddb41ef7.tar.gz llvm-aabc71485a2dce11bbad9fbddac66428ddb41ef7.tar.bz2 |
ConstantFolding: remove function in context of opaque ptrs
The function StripPtrCastKeepAS() no longer makes any sense, as we've
migrated to using opaque pointers throughout the codebase. Hence, remove
it. No changes to tests are required.
Differential Revision: https://reviews.llvm.org/D156555
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 16 |
1 files changed, 0 insertions, 16 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 83e654e..47d4358 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -861,20 +861,6 @@ Constant *CastGEPIndices(Type *SrcElemTy, ArrayRef<Constant *> Ops, return ConstantFoldConstant(C, DL, TLI); } -/// Strip the pointer casts, but preserve the address space information. -// TODO: This probably doesn't make sense with opaque pointers. -static Constant *StripPtrCastKeepAS(Constant *Ptr) { - assert(Ptr->getType()->isPointerTy() && "Not a pointer type"); - auto *OldPtrTy = cast<PointerType>(Ptr->getType()); - Ptr = cast<Constant>(Ptr->stripPointerCasts()); - auto *NewPtrTy = cast<PointerType>(Ptr->getType()); - - // Preserve the address space number of the pointer. - if (NewPtrTy->getAddressSpace() != OldPtrTy->getAddressSpace()) - Ptr = ConstantExpr::getPointerCast(Ptr, OldPtrTy); - return Ptr; -} - /// If we can symbolically evaluate the GEP constant expression, do so. Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP, ArrayRef<Constant *> Ops, @@ -909,7 +895,6 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP, BitWidth, DL.getIndexedOffsetInType( SrcElemTy, ArrayRef((Value *const *)Ops.data() + 1, Ops.size() - 1))); - Ptr = StripPtrCastKeepAS(Ptr); // If this is a GEP of a GEP, fold it all into a single GEP. while (auto *GEP = dyn_cast<GEPOperator>(Ptr)) { @@ -931,7 +916,6 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP, Ptr = cast<Constant>(GEP->getOperand(0)); SrcElemTy = GEP->getSourceElementType(); Offset += APInt(BitWidth, DL.getIndexedOffsetInType(SrcElemTy, NestedOps)); - Ptr = StripPtrCastKeepAS(Ptr); } // If the base value for this address is a literal integer value, fold the |