Commit Graph

8 Commits

Author SHA1 Message Date
Erik Eckstein
6a0b7d1f8c ObjectOutliner: create outlined arrays as let variables
This will allow load-simplification to replace a load of such an array.
2024-11-28 09:40:12 +01:00
Erik Eckstein
09b443d9e3 IRGen: fix emission of constant single-case enums without payload
This is a follow-up of https://github.com/apple/swift/pull/68516 which didn't handle the no-payload case correctly

Fixes a compiler crash

rdar://115666971
2023-09-19 10:28:51 +02:00
Erik Eckstein
9cf0229824 IRGen: fix emission of constant single-case enums
Enums which have a single case with a payload were emitted with wrong field alignement into the data section.

Fixes a miscompile:
rdar://115251963
2023-09-14 12:17:06 +02:00
Erik Eckstein
b435cf33c6 IRGen: fix a problem conver_function in a payload of a statically initialized enum
This was a stupid oversight. The `flatten` flag needs to be passed through `convert_enum` in `irgen::emitConstantValue`.

Fixes a compiler crash.

rdar://113942221
2023-08-17 10:07:20 +02:00
Erik Eckstein
a3822cd2c5 IRGen: fix a problem with 24-bit enum payloads in statically initialized global variables
IRGen crashed in case an enum, which has a 24 bit payload (e.g. three `UInt8`), is used as a payload of another enum, e.g. `Optional`, in a statically initialized global variable.

rdar://112823823
2023-07-26 15:36:31 +02:00
Erik Eckstein
3ac9fc65d7 InitializeStaticGlobals: remove dead instructions in global initializer
After removing the store it's required to remove the remaining dead instructions to avoid ownership verifier errors.

rdar://109999674
2023-05-31 14:22:48 +02:00
Erik Eckstein
92fab06d96 IRGen: fix generation of static enums with function payloads
fixes a compiler crash

rdar://109999583
2023-05-31 14:22:48 +02:00
Erik Eckstein
fe367e8013 Optimizer/IRGen: allow enums in static initializers of globals
The main change here is in IRGen which needs to be able to emit constant enum values.
Use `emitValueInjection` to create the enum constant.
Usually this method creates code in the current function.
But if all arguments to the enum are constant, the builder never has to emit an instruction.
Instead it can constant fold everything and just returns the final constant.

Also, create statically initialized let-globals as constant global (`constant` instead of `global`).
2023-05-25 16:28:41 +02:00