Skip to content

[4.2] Optimize string constants #17086

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 6 commits into from
Jun 10, 2018

Conversation

eeckstein
Copy link
Contributor

Some optimizations to generate optimal code for static String constants.
For example:

struct S {
  static let str = "abc"
}

This reduces code size for static String constants a lot.
For details see the commit list.

rdar://problem/34715367

eeckstein added 6 commits June 9, 2018 20:05
…obalOpt.

Those are needed to fully optimize static String constants.
…he data section.

So there is no need to initialize global string variables dynamically (with dispatch_once) anymore.
This is much more efficient, both in terms of code size and performance
1) don't use stringObjectOr for plain integer bits masks
2) no need to clear the extra bits on initialization.
…d right after creation.

For example:
    %0 = string_literal "abc"
    %1 = integer_literal 0x8000000000000000
    %2 = builtin "stringObjectOr_Int64" (%0, %1)
    %3 = integer_literal 0x4000000000000000
    %4 = builtin "and_Int64" (%2, %3)

In this case we know that %4 is 0.
@eeckstein
Copy link
Contributor Author

@swift-ci test and merge

@swift-ci swift-ci merged commit 7a35ad0 into swiftlang:swift-4.2-branch Jun 10, 2018
@eeckstein eeckstein deleted the string-perf-4.2 branch June 10, 2018 20:48
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