Commit Graph

2 Commits

Author SHA1 Message Date
Erik Eckstein
88a74a288c StringOptimization: optimize interpolated C strings.
Optimize code like:

   puts("\(String.self)")

Optimizing string interpolation and optimizing C-strings are both done in StringOptimization.
A second run of the StringOptimization is needed in the pipeline to optimize such code, because the result of the interpolation-optimization must be cleaned up so that the C-String optimization can kick in.

Also, StringOptimization must handle struct_extract(struct(literal)), where the struct_extract may be in a called function.
To solve a phase ordering problem with inlining String semantics and inlining the `String(stringInterpolation: DefaultStringInterpolation)` constructor, we do a simple analysis of the callee. Doing this simple "interprocedural" analysis avoids relying on inlining that String constructor.

rdar://74941849
2021-07-06 16:25:03 +02:00
Erik Eckstein
2d73b21b2b StringOptimization: optimize C string literals.
Replace a String initializer followed by String.utf8CString with a (UTF8 encoded) string literal.
This code pattern is generated when calling C functions with string literals, e.g.

  puts("hello!")

rdar://74941849
2021-03-08 08:34:53 +01:00