-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[IR] PossiblyExactOperator -> PossiblyExactInst (NFC) #72501
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -314,7 +314,9 @@ void Instruction::setHasNoSignedWrap(bool b) { | |
} | ||
|
||
void Instruction::setIsExact(bool b) { | ||
cast<PossiblyExactOperator>(this)->setIsExact(b); | ||
assert(isa<PossiblyExactInst>(this) && "Instruction must support exact flag"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idiomatic structure for these accessors appears to be to implement them on the subclass, and then dispatch via a cast to that subclass. The way you implemented this is perfectly valid, but I think it'd be better to follow the convention just to keep the code structure analogous. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, the change to the structure here was was intentional, because the old approach seemed somewhat convoluted to me, now that PossiblyExactInst is a direct descendant of Instruction. This matches the implementation of PossiblyNonNegInst now (admittedly, also added by me). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd mildly prefer the other form just for consistency, but this is very definitely non-blocking. |
||
SubclassOptionalData = (SubclassOptionalData & ~PossiblyExactInst::IsExact) | | ||
(b * PossiblyExactInst::IsExact); | ||
} | ||
|
||
void Instruction::setNonNeg(bool b) { | ||
|
@@ -354,7 +356,7 @@ void Instruction::dropPoisonGeneratingFlags() { | |
case Instruction::SDiv: | ||
case Instruction::AShr: | ||
case Instruction::LShr: | ||
cast<PossiblyExactOperator>(this)->setIsExact(false); | ||
setIsExact(false); | ||
break; | ||
|
||
case Instruction::GetElementPtr: | ||
|
@@ -416,7 +418,8 @@ void Instruction::dropUBImplyingAttrsAndMetadata() { | |
} | ||
|
||
bool Instruction::isExact() const { | ||
return cast<PossiblyExactOperator>(this)->isExact(); | ||
assert(isa<PossiblyExactInst>(this) && "Instruction must support exact flag"); | ||
return (SubclassOptionalData & PossiblyExactInst::IsExact) != 0; | ||
} | ||
|
||
void Instruction::setFast(bool B) { | ||
|
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.
This does make me wonder if I should just keep the old PossiblyExactOperator name and only do the hierarchy change. In that case "Operator" would now refer to "BinaryOperator" rather than "Instruction or ConstExpr". I've always found the overloaded use of this term confusing.