Skip to content

Conversation

@mundaym
Copy link
Contributor

@mundaym mundaym commented Mar 20, 2019

My plan is to make non-functional changes similar to this PR everywhere in IRGen where I think we need to byte swap raw bit patterns on big-endian platforms. This will usually involve SpareBitVector uses being replaced with an appropriately sized APInt so that a byte swap can be done. Eventually we'd perhaps replace SpareBitVector with APInt everywhere as per @jckarter's comment in https://forums.swift.org/t/fixing-enums-on-big-endian-systems/21730/3 but I think it would be good to do that in stages.

Use an APInt to create the spare bit mask for integer values. This
will allow us to byte swap it when we make the SpareBitVector
strictly little-endian even when targeting big-endian machine.

While editing this code I've also got rid of the goto statement
since it seemed unnecessary.

// Round Integer-Of-Unusual-Size types up to their allocation size.
unsigned allocBits = size.getValueInBits();
assert(allocBits >= intTy->getBitWidth());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dropped this assertion since llvm::APInt::getBitsSetFrom already asserts this and the earlier DataLayout assertion will catch it first anyway probably.

Copy link
Contributor

@jckarter jckarter left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning this up!

@jckarter
Copy link
Contributor

@swift-ci Please test

@jckarter jckarter merged commit cdf9de9 into swiftlang:master Mar 21, 2019
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.

2 participants