[llvm] [SCCP] Use Small Vector for struct (PR #226638)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 22:20:07 PDT 2026
https://github.com/aokblast created https://github.com/llvm/llvm-project/pull/226638
None
>From be7d200665e4b90b2e4d7977bef350202c62aa68 Mon Sep 17 00:00:00 2001
From: ShengYi Hung <aokblast at FreeBSD.org>
Date: Sat, 26 Sep 2026 00:17:07 -0500
Subject: [PATCH] [SCCP] Use Small Vector for struct
---
llvm/include/llvm/Transforms/Utils/SCCPSolver.h | 2 +-
llvm/lib/Transforms/Utils/SCCPSolver.cpp | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/llvm/include/llvm/Transforms/Utils/SCCPSolver.h b/llvm/include/llvm/Transforms/Utils/SCCPSolver.h
index 88a4df83304f1a..2200c8c0ce51e6 100644
--- a/llvm/include/llvm/Transforms/Utils/SCCPSolver.h
+++ b/llvm/include/llvm/Transforms/Utils/SCCPSolver.h
@@ -137,7 +137,7 @@ class SCCPSolver {
// block to the 'To' basic block is currently feasible.
LLVM_ABI bool isEdgeFeasible(BasicBlock *From, BasicBlock *To) const;
- LLVM_ABI std::vector<ValueLatticeElement>
+ LLVM_ABI SmallVector<ValueLatticeElement, 4>
getStructLatticeValueFor(Value *V) const;
LLVM_ABI void removeLatticeValueFor(Value *V);
diff --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
index 114389ff057a7e..a570afb728c056 100644
--- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp
+++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
@@ -972,8 +972,8 @@ class SCCPInstVisitor : public InstVisitor<SCCPInstVisitor> {
bool isEdgeFeasible(BasicBlock *From, BasicBlock *To) const;
- std::vector<ValueLatticeElement> getStructLatticeValueFor(Value *V) const {
- std::vector<ValueLatticeElement> StructValues;
+ SmallVector<ValueLatticeElement, 4> getStructLatticeValueFor(Value *V) const {
+ SmallVector<ValueLatticeElement, 4> StructValues;
auto *STy = dyn_cast<StructType>(V->getType());
assert(STy && "getStructLatticeValueFor() can be called only on structs");
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
@@ -1209,10 +1209,10 @@ Constant *SCCPInstVisitor::getConstant(const ValueLatticeElement &LV,
Constant *SCCPInstVisitor::getConstantOrNull(Value *V) const {
Constant *Const = nullptr;
if (V->getType()->isStructTy()) {
- std::vector<ValueLatticeElement> LVs = getStructLatticeValueFor(V);
+ SmallVector<ValueLatticeElement, 4> LVs = getStructLatticeValueFor(V);
if (any_of(LVs, SCCPSolver::isOverdefined))
return nullptr;
- std::vector<Constant *> ConstVals;
+ SmallVector<Constant *, 4> ConstVals;
auto *ST = cast<StructType>(V->getType());
for (unsigned I = 0, E = ST->getNumElements(); I != E; ++I) {
const ValueLatticeElement &LV = LVs[I];
@@ -2448,7 +2448,7 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) const {
return Visitor->isEdgeFeasible(From, To);
}
-std::vector<ValueLatticeElement>
+SmallVector<ValueLatticeElement, 4>
SCCPSolver::getStructLatticeValueFor(Value *V) const {
return Visitor->getStructLatticeValueFor(V);
}
More information about the llvm-commits
mailing list