swift
7f684b62 - SIL optimizer: Add a new string optimization.

Commit
4 years ago
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
Author
Committer
Parents
  • include/swift
    • AST
      • File
        ASTContext.h
      • File
        SemanticAttrs.def
    • SILOptimizer/PassManager
      • File
        Passes.def
  • lib
    • AST
      • File
        ASTContext.cpp
    • SILOptimizer
      • PassManager
        • File
          PassPipeline.cpp
      • Transforms
        • File
          CMakeLists.txt
        • File
          StringOptimization.cpp
  • test
    • SILOptimizer
      • string_optimization.sil
      • File
        string_optimization.swift
    • stdlib
      • File
        TypeName.swift
      • File
        TypeNameInterpolation.swift