Skip to content

Commit aabc714

Browse files
committed
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
1 parent 0a5e0d3 commit aabc714

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

llvm/lib/Analysis/ConstantFolding.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -861,20 +861,6 @@ Constant *CastGEPIndices(Type *SrcElemTy, ArrayRef<Constant *> Ops,
861861
return ConstantFoldConstant(C, DL, TLI);
862862
}
863863

864-
/// Strip the pointer casts, but preserve the address space information.
865-
// TODO: This probably doesn't make sense with opaque pointers.
866-
static Constant *StripPtrCastKeepAS(Constant *Ptr) {
867-
assert(Ptr->getType()->isPointerTy() && "Not a pointer type");
868-
auto *OldPtrTy = cast<PointerType>(Ptr->getType());
869-
Ptr = cast<Constant>(Ptr->stripPointerCasts());
870-
auto *NewPtrTy = cast<PointerType>(Ptr->getType());
871-
872-
// Preserve the address space number of the pointer.
873-
if (NewPtrTy->getAddressSpace() != OldPtrTy->getAddressSpace())
874-
Ptr = ConstantExpr::getPointerCast(Ptr, OldPtrTy);
875-
return Ptr;
876-
}
877-
878864
/// If we can symbolically evaluate the GEP constant expression, do so.
879865
Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
880866
ArrayRef<Constant *> Ops,
@@ -909,7 +895,6 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
909895
BitWidth,
910896
DL.getIndexedOffsetInType(
911897
SrcElemTy, ArrayRef((Value *const *)Ops.data() + 1, Ops.size() - 1)));
912-
Ptr = StripPtrCastKeepAS(Ptr);
913898

914899
// If this is a GEP of a GEP, fold it all into a single GEP.
915900
while (auto *GEP = dyn_cast<GEPOperator>(Ptr)) {
@@ -931,7 +916,6 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
931916
Ptr = cast<Constant>(GEP->getOperand(0));
932917
SrcElemTy = GEP->getSourceElementType();
933918
Offset += APInt(BitWidth, DL.getIndexedOffsetInType(SrcElemTy, NestedOps));
934-
Ptr = StripPtrCastKeepAS(Ptr);
935919
}
936920

937921
// If the base value for this address is a literal integer value, fold the

0 commit comments

Comments
 (0)