Commit Graph

6 Commits

Author SHA1 Message Date
Hamish Knight
97c3275f6b Add missing %target-codesigns to a couple of tests 2023-09-12 14:45:51 +01:00
Kuba Mracek
5dac59ce71 Move TargetConstantFolding pass to the simplification passes in Swift, enable using MemoryLayout's .size, .stride, .alignment fields in forced-const global initializers 2023-07-31 10:54:07 -07:00
Erik Eckstein
1e6511e7c0 Pass Pipeline: replace the old GlobalOpt with the new InitializeStaticGlobals and ReadOnlyGlobalVariablesPass passes. 2023-05-08 21:23:36 +02:00
Erik Eckstein
f5a0519289 fix Builtin.sizeof et al for metatypes
Those builtins always need to assume a thick metatype which is a pointer.
In other words the builtins need to use the maximally abstracted type.

rdar://108308786
2023-04-21 21:08:49 +02:00
Erik Eckstein
1cbea04103 run the TargetConstantFolding pass also at -Onone
This is important for performance diagnostics: it’s assumed that (non-generic) MemoryLayout constants do not need to create metadata at runtime. At Onone this is only guaranteed if the TargetConstantFolding pass runs.

rdar://94836837
2022-07-07 08:35:04 +02:00
Erik Eckstein
f420468b27 SILOptimizer: add a pass to perform target specific constant folding.
TargetConstantFolding performs constant folding for target-specific values:

```
  MemoryLayout<S>.size
  MemoryLayout<S>.alignment
  MemoryLayout<S>.stride
```

Constant folding those expressions in the middle of the SIL pipeline enables other optimizations to e.g. allow such expressions in statically allocated global variables (done by the GlobalOpt pass).

The implementation requires to create a temporary IRGenModule, which is used to get actual constant sizes/alignments from IRGen's type lowering.

rdar://94831524
2022-06-23 22:16:42 +02:00