Skip to content

[ConstExpr] Relax expectations in ArrayAppendElement to allow direct-passed element #77471

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 1 commit into from
Nov 9, 2024

Conversation

kubamracek
Copy link
Contributor

When using arrays in a constant-folding string interpolation, under Embedded Swift, we can hit an assert:

Assertion failed: (getKind() == Address), function getAddressValue, file SILConstants.cpp, line 674.
...
7  swift-frontend           0x00000001062bd580 swift::SymbolicValue::getAddressValue(llvm::SmallVectorImpl<unsigned int>&) const (.cold.2) + 0
8  swift-frontend           0x00000001012eb390 swift::SymbolicValue::getAddressValue(llvm::SmallVectorImpl<unsigned int>&) const + 136
9  swift-frontend           0x0000000101021678 swift::ConstExprFunctionState::loadAddrValue(swift::SILValue, swift::SymbolicValue) + 88
10 swift-frontend           0x000000010101ea04 swift::ConstExprFunctionState::computeWellKnownCallResult(swift::ApplyInst*, WellKnownFunction) + 2732

This PR fixes that by relaxing the expectation inside the handling of WellKnownFunction::ArrayAppendElement, which have only been expecting that Array.append is generic (non-specialized) and takes the element parameter indirectly. That's not always true under Embedded Swift where Array.append is going to be specialized.

rdar://139351327

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek
Copy link
Contributor Author

@swift-ci please built toolchain macOS platform

@kubamracek
Copy link
Contributor Author

@swift-ci please build toolchain macOS platform

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek
Copy link
Contributor Author

@swift-ci please build toolchain macOS platform

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek
Copy link
Contributor Author

@swift-ci please build toolchain macOS platform

@kubamracek kubamracek enabled auto-merge November 8, 2024 22:37
@kubamracek kubamracek merged commit 3c22407 into swiftlang:main Nov 9, 2024
5 of 6 checks passed
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