-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Some improvements for inline bitfields in SILNode, SILBasicBlock and Operand #72485
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
In contrast to `assert` and similar functions, `require` works in no-assert builds the same way as in debug builds. It can be used to check invariants also in release builds.
… functions This fixes a bug with can cause OperandSet to misbehave for instructions which were moved from another function.
* Let the customBits and lastInitializedBitfieldID share a single uint64_t. This increases the number of available bits in SILNode and Operand from 8 to 20. Also, it simplifies the Operand class because no PointerIntPairs are used anymore to store the operand pointer fields. * Instead make the "deleted" flag a separate bool field in SILNode (instead of encoding it with the sign of lastInitializedBitfieldID). Another simplification * Enable important invariant checks also in release builds by using `require` instead of `assert`. Not catching such errors in release builds would be a disaster. * Let the Swift optimization passes use all the available bits and not only a fixed amount of 8 (SILNode) and 16 (SILBasicBlock).
Implemented by bridging the C++ OperandSet, similar to BasicBlockSet and NodeSet
@swift-ci test |
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.
Nice!
Thanks! |
/// Checks the `condition` and if it's false abort with `message`. | ||
/// In contrast to `assert` and similar functions, `require` works in | ||
/// no-assert builds the same way as in debug builds. | ||
inline void require(bool condition, const char *message) { |
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.
@eeckstein Shouldn't this be in the llvm or swift namespace rather than the global namespace
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.
yes, that makes sense
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.
Clear operand bit fields of instructions which are moved between functions. This fixes a bug with can cause
OperandSet
to misbehave for instructions which were moved from another function.Let the
customBits
andlastInitializedBitfieldID
share a singleuint64_t
. This increases the number of available bits inSILNode
andOperand
from 8 to 20 without increasing the size of those data types. Also, it simplifies theOperand
class because noPointerIntPair
s are used anymore to store the operand pointer fields.Instead make the "deleted" flag a separate bool field in
SILNode
(instead of encoding it with the sign oflastInitializedBitfieldID
) - another simplification.Enable important invariant checks also in release builds by using
require
instead ofassert
. Not catching such errors in release builds would be a disaster.Let the Swift optimization passes use all the available bits and not only a fixed amount of 8 (
SILNode
) and 16 (SILBasicBlock
).Add
OperandSet
andOperandWorklist
in SwiftCompilerSources