Skip to content

Commit db60a95

Browse files
committed
ConstantFold: drop PointeeTy when folding GEP (NFC)
The PointeeTy argument is not respected. To avoid misleading callers, drop the argument.
1 parent 95c0c78 commit db60a95

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

llvm/include/llvm/IR/ConstantFold.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace llvm {
5252
Constant *V2);
5353
Constant *ConstantFoldCompareInstruction(CmpInst::Predicate Predicate,
5454
Constant *C1, Constant *C2);
55-
Constant *ConstantFoldGetElementPtr(Type *Ty, Constant *C,
55+
Constant *ConstantFoldGetElementPtr(Constant *C,
5656
std::optional<ConstantRange> InRange,
5757
ArrayRef<Value *> Idxs);
5858
} // End llvm namespace

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5127,7 +5127,7 @@ static Value *simplifyGEPInst(Type *SrcTy, Value *Ptr,
51275127
return nullptr;
51285128

51295129
if (!ConstantExpr::isSupportedGetElementPtr(SrcTy))
5130-
return ConstantFoldGetElementPtr(SrcTy, cast<Constant>(Ptr), std::nullopt,
5130+
return ConstantFoldGetElementPtr(cast<Constant>(Ptr), std::nullopt,
51315131
Indices);
51325132

51335133
auto *CE =

llvm/lib/IR/ConstantFold.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ Constant *llvm::ConstantFoldCompareInstruction(CmpInst::Predicate Predicate,
13121312
return nullptr;
13131313
}
13141314

1315-
Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C,
1315+
Constant *llvm::ConstantFoldGetElementPtr(Constant *C,
13161316
std::optional<ConstantRange> InRange,
13171317
ArrayRef<Value *> Idxs) {
13181318
if (Idxs.empty()) return C;

llvm/lib/IR/Constants.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ static bool constantIsDead(const Constant *C, bool RemoveDeadUsers) {
732732
ReplaceableMetadataImpl::SalvageDebugInfo(*C);
733733
const_cast<Constant *>(C)->destroyConstant();
734734
}
735-
735+
736736
return true;
737737
}
738738

@@ -2509,7 +2509,7 @@ Constant *ConstantExpr::getGetElementPtr(Type *Ty, Constant *C,
25092509
assert(Ty && "Must specify element type");
25102510
assert(isSupportedGetElementPtr(Ty) && "Element type is unsupported!");
25112511

2512-
if (Constant *FC = ConstantFoldGetElementPtr(Ty, C, InRange, Idxs))
2512+
if (Constant *FC = ConstantFoldGetElementPtr(C, InRange, Idxs))
25132513
return FC; // Fold a few common cases.
25142514

25152515
assert(GetElementPtrInst::getIndexedType(Ty, Idxs) && "GEP indices invalid!");

0 commit comments

Comments
 (0)