-
Notifications
You must be signed in to change notification settings - Fork 15.1k
IR: Remove null UseList checks in hasNUses methods #165929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-llvm-ir Author: Matt Arsenault (arsenm) ChangesFull diff: https://github.com/llvm/llvm-project/pull/165929.diff 1 Files Affected:
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index b775cbb0c7920..95d61a987f6c1 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -148,18 +148,10 @@ void Value::destroyValueName() {
}
bool Value::hasNUses(unsigned N) const {
- if (!UseList)
- return N == 0;
-
- // TODO: Disallow for ConstantData and remove !UseList check?
return hasNItems(use_begin(), use_end(), N);
}
bool Value::hasNUsesOrMore(unsigned N) const {
- // TODO: Disallow for ConstantData and remove !UseList check?
- if (!UseList)
- return N == 0;
-
return hasNItemsOrMore(use_begin(), use_end(), N);
}
|
428c6d6 to
ffa6cac
Compare
nikic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There do not appear to be any cases where this is used. This does introduce an odd asyemmtry where use_empty is not equivalent to hasNUses(0).
Co-authored-by: Nikita Popov <npopov@redhat.com>
96e04af to
f83ef56
Compare
|
Hm, got a for (Value *Op : Item->operands())
if (Op->hasNUses(1))Was called and I believe |
You shouldn't rely on the use lists of ConstantData. We still tolerate use_empty checks on them, mostly because there's just too much code to fix at a time |
|
@arsenm it wasn't relying on uselists of a constant data. It was relying on Also, |
That's a pain. Probably should revert this then |
This reverts commit 93e860e. hasOneUse still has the null check, and it seems bad to be logically inconsistent across multiple of these predicate functions.

There do not appear to be any cases where this is used.
This does introduce an odd asyemmtry where use_empty is not
equivalent to hasNUses(0).