Commit 05fcf5f
committed
Fix OSSA RAUW utility for move_value that changes ownership.
CSE "looks through" ownership operations, which can lead to problematic substitutions. This fix cleans up owned operands even when the newly substituted value has no ownership.
For example:
%0 = enum $Optional<Interface>, #Optional.none!enumelt
%1 = move_value [lexical] %0
%2 = enum $Optional<Interface>, #Optional.none!enumelt
%3 = struct $EndpointCommon (%2)
%4 = struct $EndpointCommon (%1)
CSE combines the two .none enums:
%0 = enum $Optional<Interface>, #Optional.none!enumelt
%2 = enum $Optional<Interface>, #Optional.none!enumelt
Then combines the two structs:
%3 = struct $EndpointCommon (%2)
%4 = struct $EndpointCommon (%1)
Leaving a dead move_value:
%1 = move_value [lexical] %0
which is invalid OSSA. Now, when replacing the owned struct, we add destroys for its operands.
Fixes rdar://156431548 Error! Found a leaked owned value that was never consumed.1 parent 663ec93 commit 05fcf5f
File tree
3 files changed
+43
-4
lines changed- lib/SILOptimizer/Utils
- test/SILOptimizer
3 files changed
+43
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1241 | 1241 | | |
1242 | 1242 | | |
1243 | 1243 | | |
1244 | | - | |
| 1244 | + | |
1245 | 1245 | | |
1246 | 1246 | | |
1247 | 1247 | | |
1248 | | - | |
| 1248 | + | |
| 1249 | + | |
1249 | 1250 | | |
1250 | | - | |
| 1251 | + | |
1251 | 1252 | | |
1252 | 1253 | | |
1253 | 1254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1062 | 1062 | | |
1063 | 1063 | | |
1064 | 1064 | | |
1065 | | - | |
| 1065 | + | |
1066 | 1066 | | |
1067 | 1067 | | |
1068 | 1068 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1126 | 1126 | | |
1127 | 1127 | | |
1128 | 1128 | | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
0 commit comments