Skip to content

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

Merged
merged 4 commits into from
Mar 21, 2024

Conversation

eeckstein
Copy link
Contributor

@eeckstein eeckstein commented Mar 21, 2024

  • 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 and lastInitializedBitfieldID share a single uint64_t. This increases the number of available bits in SILNode and Operand from 8 to 20 without increasing the size of those data types. 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).

  • Add OperandSet and OperandWorklist in SwiftCompilerSources

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
@eeckstein eeckstein requested review from gottesmm and atrick March 21, 2024 14:55
@eeckstein
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@gottesmm
Copy link
Contributor

gottesmm commented Apr 3, 2024

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) {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants