Skip to content

Add some instruction simplifications #70494

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 3 commits into from
Dec 17, 2023

Conversation

eeckstein
Copy link
Contributor

  • removes an enum - switch_enum pairs
  • constant fold null pointer checks against string literals

This enables to put StaticString("some string literal").utf8Start into a statically initialized global

Replace
```
    %1 = enum $E, #someCase, %payload
    switch_enum %1, case #someCase: bb1, ...
  bb1(%payloadArgument):
```
->
```
  br bb1(%payload)
  bb1(%payloadArgument):
```
…string literals

A pointer to a string literal is never null
Check that `StaticString("some string literal").utf8Start` can be put into a statically initialized global
@eeckstein eeckstein requested a review from kubamracek December 15, 2023 16:14
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein
Copy link
Contributor Author

@swift-ci benchmark

@eeckstein eeckstein merged commit 4eddc1d into swiftlang:main Dec 17, 2023
@eeckstein eeckstein deleted the instruction-simplifications branch December 18, 2023 12:53
@@ -38,8 +38,14 @@ struct MyStruct5 {
}
@_section("__TEXT,__mysection") var g_MyStruct5: MyStruct5 = MyStruct5(q: MyStruct4(a: 42, s: MyStruct1(a: 43, b: 44)), r: MyStruct4(a: 42, s: MyStruct1(a: 43, b: 44)))

@_section("__TEXT,__mysection") let utf8OfStaticString = StaticString("hello").utf8Start
Copy link
Member

Choose a reason for hiding this comment

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

@eeckstein, strangely this broke on the 32-bit Android armv7 CI but not on the aarch64 CI:

/home/ubuntu/jenkins/workspace/oss-swift-RA-linux-ubuntu-16.04-android/swift/test/IRGen/section_structs.swift:41:37: error: global variable must be a compile-time constant to use @_section attribute
@_section("__TEXT,__mysection") let utf8OfStaticString = StaticString("hello").utf8Start
                                    ^

This compiler on the Android CI is built with a full bootstrap on linux, as that CI has no prebuilt Swift compiler installed, so the swift-syntax parser is not built. Maybe that has something to do with it, but weird that it only hits for 32-bit compilation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@finagolfin do you have any error log or a link to the ci failure?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's disable the test for 32-bit

Copy link
Member

Choose a reason for hiding this comment

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

SGTM

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