Commit Graph

3 Commits

Author SHA1 Message Date
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
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