Commit Graph

6 Commits

Author SHA1 Message Date
Erik Eckstein
b8485d6d14 StringOptimization: fix a crash when constant folding the type name of an inner class
rdar://problem/66540633
2020-08-05 11:34:34 +02:00
Erik Eckstein
63c275c45f SILOptimizer: move String concatination optimization from SILCombine/ConstantFolding to StringOptimization.
This simplifies some code and it's not required to try this optimization on every run of SILCombine and ConstantPropagation.
2020-08-04 16:16:11 +02:00
Erik Eckstein
e3f3b75208 StringOptimization: handle static let variables for String constant folding.
For example, constant fold:

struct Str {
    static let s = "hello"
}
...
let x = "<\(Str.s)>"
2020-08-03 12:01:29 +02:00
Slava Pestov
0ef12ec8aa SIL: Replace some calls to getDeclaredType() with getDeclaredInterfaceType() 2020-07-31 13:39:02 -04:00
Erik Eckstein
5f3e79b84e StringOptimization: bug fixes
Fix some bugs in the optimization and in the test files.

rdar://problem/66283894
2020-07-30 11:32:39 +02:00
Erik Eckstein
7f684b62e2 SIL optimizer: Add a new string optimization.
Optimizes String operations with constant operands.

Specifically:
  * Replaces x.append(y) with x = y if x is empty.
  * Removes x.append("")
  * Replaces x.append(y) with x = x + y if x and y are constant strings.
  * Replaces _typeName(T.self) with a constant string if T is statically known.

With this optimization it's possible to constant fold string interpolations, like "the \(Int.self) type" -> "the Int type"

This new pass runs on high-level SIL, where semantic calls are still in place.

rdar://problem/65642843
2020-07-27 21:32:56 +02:00