[llvm] ConstantFold: drop PointeeTy when folding GEP (NFC) (PR #125562)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 3 11:46:43 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Ramkumar Ramachandra (artagnon)
<details>
<summary>Changes</summary>
The PointeeTy argument is not respected. To avoid misleading callers, drop the argument.
---
Full diff: https://github.com/llvm/llvm-project/pull/125562.diff
4 Files Affected:
- (modified) llvm/include/llvm/IR/ConstantFold.h (+1-1)
- (modified) llvm/lib/Analysis/InstructionSimplify.cpp (+1-1)
- (modified) llvm/lib/IR/ConstantFold.cpp (+1-1)
- (modified) llvm/lib/IR/Constants.cpp (+2-2)
``````````diff
diff --git a/llvm/include/llvm/IR/ConstantFold.h b/llvm/include/llvm/IR/ConstantFold.h
index 42043d365b2d3e..c667affd56e91d 100644
--- a/llvm/include/llvm/IR/ConstantFold.h
+++ b/llvm/include/llvm/IR/ConstantFold.h
@@ -52,7 +52,7 @@ namespace llvm {
Constant *V2);
Constant *ConstantFoldCompareInstruction(CmpInst::Predicate Predicate,
Constant *C1, Constant *C2);
- Constant *ConstantFoldGetElementPtr(Type *Ty, Constant *C,
+ Constant *ConstantFoldGetElementPtr(Constant *C,
std::optional<ConstantRange> InRange,
ArrayRef<Value *> Idxs);
} // End llvm namespace
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index d69747e30f884d..f2da230346bbee 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -5127,7 +5127,7 @@ static Value *simplifyGEPInst(Type *SrcTy, Value *Ptr,
return nullptr;
if (!ConstantExpr::isSupportedGetElementPtr(SrcTy))
- return ConstantFoldGetElementPtr(SrcTy, cast<Constant>(Ptr), std::nullopt,
+ return ConstantFoldGetElementPtr(cast<Constant>(Ptr), std::nullopt,
Indices);
auto *CE =
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index b577f69eeaba0b..c78069ade42d15 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -1312,7 +1312,7 @@ Constant *llvm::ConstantFoldCompareInstruction(CmpInst::Predicate Predicate,
return nullptr;
}
-Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C,
+Constant *llvm::ConstantFoldGetElementPtr(Constant *C,
std::optional<ConstantRange> InRange,
ArrayRef<Value *> Idxs) {
if (Idxs.empty()) return C;
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 33f4dc78c6d3f9..c94d6548364291 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -732,7 +732,7 @@ static bool constantIsDead(const Constant *C, bool RemoveDeadUsers) {
ReplaceableMetadataImpl::SalvageDebugInfo(*C);
const_cast<Constant *>(C)->destroyConstant();
}
-
+
return true;
}
@@ -2509,7 +2509,7 @@ Constant *ConstantExpr::getGetElementPtr(Type *Ty, Constant *C,
assert(Ty && "Must specify element type");
assert(isSupportedGetElementPtr(Ty) && "Element type is unsupported!");
- if (Constant *FC = ConstantFoldGetElementPtr(Ty, C, InRange, Idxs))
+ if (Constant *FC = ConstantFoldGetElementPtr(C, InRange, Idxs))
return FC; // Fold a few common cases.
assert(GetElementPtrInst::getIndexedType(Ty, Idxs) && "GEP indices invalid!");
``````````
</details>
https://github.com/llvm/llvm-project/pull/125562
More information about the llvm-commits
mailing list