Skip to content

Conversation

AnthonyLatsis
Copy link
Collaborator

Follow-up to #84052.

ac61901 backfired when building the stdlib on rebranch. This time the problem is reversed: we should be interpreting an integer as unsigned where we no longer do, here:

let charLiteral = builder.createIntegerLiteral(Int(stringLiteral.value[index]), type: type)

Rather than treating integers as signed by default, make Builder.createIntegerLiteral accept a generic FixedWidthInteger, and manipulate the value based on the generic type argument's signedness.

This doesn't entirely define away unintentional sign extensions, but makes this mistake of humouring the parameter type less likely.

ac61901 backfired when building the
stdlib on rebranch. This time the problem is reversed: we should be
interpreting an integer as unsigned where we no longer do, here:
https://github.com/swiftlang/swift/blob/8f7af45115e373e05d3419ab272f02700bd8a48c/SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyLoad.swift#L78.

Rather than treating integers as signed by default, make
`Builder.createIntegerLiteral` accept a generic `FixedWidthInteger`, and
manipulate the value based on the generic type argument's signedness.

This doesn't entirely define away unintentional sign extensions, but
makes this mistake of humouring the parameter type less likely.
@AnthonyLatsis
Copy link
Collaborator Author

@swift-ci please test

@AnthonyLatsis
Copy link
Collaborator Author

Making sure this passes on rebranch in #81190

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm

@AnthonyLatsis AnthonyLatsis merged commit 1dc81a2 into main Sep 25, 2025
5 checks passed
@AnthonyLatsis AnthonyLatsis deleted the jepa-main2 branch September 25, 2025 15:14
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