aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Value.cpp
diff options
context:
space:
mode:
authorKirill Stoimenov <kstoimenov@google.com>2025-05-07 00:02:04 +0000
committerKirill Stoimenov <kstoimenov@google.com>2025-05-07 00:07:55 +0000
commit5936c02c8b9c6d1476f7830517781ce8b6e26e75 (patch)
tree0f8d157b6deead16af6296f4a9a360848bf661d5 /llvm/lib/IR/Value.cpp
parent0274232b87177779e5c985eca06df22bf140f6cb (diff)
downloadllvm-5936c02c8b9c6d1476f7830517781ce8b6e26e75.zip
llvm-5936c02c8b9c6d1476f7830517781ce8b6e26e75.tar.gz
llvm-5936c02c8b9c6d1476f7830517781ce8b6e26e75.tar.bz2
Revert "IR: Remove uselist for constantdata (#137313)"
Possibly breaks the build: https://lab.llvm.org/buildbot/#/builders/24/builds/8119 This reverts commit 87f312aad6ede636cd2de5d18f3058bf2caf5651.
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r--llvm/lib/IR/Value.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index 74a9605..aa97b70 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -53,7 +53,7 @@ static inline Type *checkType(Type *Ty) {
Value::Value(Type *ty, unsigned scid)
: SubclassID(scid), HasValueHandle(0), SubclassOptionalData(0),
SubclassData(0), NumUserOperands(0), IsUsedByMD(false), HasName(false),
- HasMetadata(false), VTy(checkType(ty)) {
+ HasMetadata(false), VTy(checkType(ty)), UseList(nullptr) {
static_assert(ConstantFirstVal == 0, "!(SubclassID < ConstantFirstVal)");
// FIXME: Why isn't this in the subclass gunk??
// Note, we cannot call isa<CallInst> before the CallInst has been
@@ -148,14 +148,10 @@ void Value::destroyValueName() {
}
bool Value::hasNUses(unsigned N) const {
- if (!hasUseList())
- return Uses.Count == N;
return hasNItems(use_begin(), use_end(), N);
}
bool Value::hasNUsesOrMore(unsigned N) const {
- if (!hasUseList())
- return Uses.Count >= N;
return hasNItemsOrMore(use_begin(), use_end(), N);
}
@@ -236,8 +232,6 @@ void Value::dropDroppableUse(Use &U) {
}
bool Value::isUsedInBasicBlock(const BasicBlock *BB) const {
- assert(hasUseList() && "ConstantData has no use-list");
-
// This can be computed either by scanning the instructions in BB, or by
// scanning the use list of this Value. Both lists can be very long, but
// usually one is quite short.
@@ -259,9 +253,6 @@ bool Value::isUsedInBasicBlock(const BasicBlock *BB) const {
}
unsigned Value::getNumUses() const {
- if (!hasUseList())
- return Uses.Count;
-
return (unsigned)std::distance(use_begin(), use_end());
}
@@ -508,7 +499,6 @@ static bool contains(Value *Expr, Value *V) {
#endif // NDEBUG
void Value::doRAUW(Value *New, ReplaceMetadataUses ReplaceMetaUses) {
- assert(hasUseList() && "Cannot replace constant data");
assert(New && "Value::replaceAllUsesWith(<null>) is invalid!");
assert(!contains(New, this) &&
"this->replaceAllUsesWith(expr(this)) is NOT valid!");
@@ -522,7 +512,7 @@ void Value::doRAUW(Value *New, ReplaceMetadataUses ReplaceMetaUses) {
ValueAsMetadata::handleRAUW(this, New);
while (!materialized_use_empty()) {
- Use &U = *Uses.List;
+ Use &U = *UseList;
// Must handle Constants specially, we cannot call replaceUsesOfWith on a
// constant because they are uniqued.
if (auto *C = dyn_cast<Constant>(U.getUser())) {
@@ -854,7 +844,7 @@ bool Value::canBeFreed() const {
// which is why we need the explicit opt in on a per collector basis.
if (!F->hasGC())
return true;
-
+
const auto &GCName = F->getGC();
if (GCName == "statepoint-example") {
auto *PT = cast<PointerType>(this->getType());
@@ -1102,12 +1092,12 @@ const Value *Value::DoPHITranslation(const BasicBlock *CurBB,
LLVMContext &Value::getContext() const { return VTy->getContext(); }
void Value::reverseUseList() {
- if (!Uses.List || !Uses.List->Next || !hasUseList())
+ if (!UseList || !UseList->Next)
// No need to reverse 0 or 1 uses.
return;
- Use *Head = Uses.List;
- Use *Current = Uses.List->Next;
+ Use *Head = UseList;
+ Use *Current = UseList->Next;
Head->Next = nullptr;
while (Current) {
Use *Next = Current->Next;
@@ -1116,8 +1106,8 @@ void Value::reverseUseList() {
Head = Current;
Current = Next;
}
- Uses.List = Head;
- Head->Prev = &Uses.List;
+ UseList = Head;
+ Head->Prev = &UseList;
}
bool Value::isSwiftError() const {