Commit Graph

19 Commits

Author SHA1 Message Date
Erik Eckstein
6a020f8f15 Stabilize and simplify SIL linkage and serialization
The main point of this change is to make sure that a shared function always has a body: both, in the optimizer pipeline and in the swiftmodule file.
This is important because the compiler always needs to emit code for a shared function. Shared functions cannot be referenced from outside the module.
In several corner cases we missed to maintain this invariant which resulted in unresolved-symbol linker errors.

As side-effect of this change we can drop the shared_external SIL linkage and the IsSerializable flag, which simplifies the serialization and linkage concept.
2022-03-09 15:28:05 +01:00
Min-Yih Hsu
343d842394 [SIL][DebugInfo] PATCH 3/3: Deprecate debug_value_addr SIL instruciton
This patch removes all references to DebugValueAddrInst class and
debug_value_addr instruction in textual SIL files.
2021-08-31 12:01:04 -07:00
Min-Yih Hsu
e1023bc323 [DebugInfo] PATCH 2/3: Duplicate logics regarding debug_value_addr
This patch replace all in-memory objects of DebugValueAddrInst with
DebugValueInst + op_deref, and duplicates logics that handles
DebugValueAddrInst with the latter. All related check in the tests
have been updated as well.

Note that this patch neither remove the DebugValueAddrInst class nor
remove `debug_value_addr` syntax in the test inputs.
2021-08-31 11:57:56 -07:00
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
f3d1c34eb5 StringOptimization: don't constant fold dynamic Self type names.
This wrongly results in "Self" instead of the real type name.

rdar://76113269
2021-04-02 08:41:01 +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
swift-ci
0bd029cce2 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-05 09:55:55 -07:00
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
Nathan Hawes
3707cfab12 Fix build failures due to Tyoe::dump() api difference + string conversions 2020-08-04 14:19:15 -07:00
Nathan Hawes
607e2b8822 Manually merge remote-tracking branch 'upstream/master' into HEAD 2020-08-04 13:47:48 -07: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
swift-ci
74a22bc619 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-03 06:03:55 -07: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
swift-ci
a0a181159c Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-31 16:07:19 -07:00
Slava Pestov
0ef12ec8aa SIL: Replace some calls to getDeclaredType() with getDeclaredInterfaceType() 2020-07-31 13:39:02 -04:00
swift-ci
8ba84b3351 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-30 05:03:25 -07: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
Nathan Hawes
774dfbf2af Fix an implicit StringRef -> std::string conversion issue in StringOptimization.cpp 2020-07-28 13:17:15 -07: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