Skip to content

Commit fdf4d13

Browse files
committed
Revert "Avoid generating address phis in ArrayPropertyOpt"
This reverts commit 17285c0.
1 parent c9c9036 commit fdf4d13

File tree

2 files changed

+8
-62
lines changed

2 files changed

+8
-62
lines changed

lib/SILOptimizer/LoopTransforms/ArrayPropertyOpt.cpp

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,18 @@
5353
#define DEBUG_TYPE "array-property-opt"
5454

5555
#include "ArrayOpt.h"
56-
#include "swift/SIL/BasicBlockBits.h"
57-
#include "swift/SIL/CFG.h"
58-
#include "swift/SIL/DebugUtils.h"
59-
#include "swift/SIL/InstructionUtils.h"
60-
#include "swift/SIL/LoopInfo.h"
61-
#include "swift/SIL/Projection.h"
62-
#include "swift/SIL/SILCloner.h"
6356
#include "swift/SILOptimizer/Analysis/ArraySemantic.h"
6457
#include "swift/SILOptimizer/Analysis/LoopAnalysis.h"
6558
#include "swift/SILOptimizer/PassManager/Transforms.h"
66-
#include "swift/SILOptimizer/Utils/BasicBlockOptUtils.h"
6759
#include "swift/SILOptimizer/Utils/CFGOptUtils.h"
6860
#include "swift/SILOptimizer/Utils/SILSSAUpdater.h"
61+
#include "swift/SIL/CFG.h"
62+
#include "swift/SIL/DebugUtils.h"
63+
#include "swift/SIL/InstructionUtils.h"
64+
#include "swift/SIL/Projection.h"
65+
#include "swift/SIL/LoopInfo.h"
66+
#include "swift/SIL/BasicBlockBits.h"
67+
#include "swift/SIL/SILCloner.h"
6968
#include "llvm/ADT/SmallSet.h"
7069
#include "llvm/Support/CommandLine.h"
7170
#include "llvm/Support/Debug.h"
@@ -86,8 +85,6 @@ class ArrayPropertiesAnalysis {
8685
SILBasicBlock *Preheader;
8786
DominanceInfo *DomTree;
8887

89-
SinkAddressProjections sinkProj;
90-
9188
llvm::DenseMap<SILFunction *, uint32_t> InstCountCache;
9289
llvm::SmallSet<SILValue, 16> HoistableArray;
9390

@@ -171,18 +168,13 @@ class ArrayPropertiesAnalysis {
171168

172169
bool FoundHoistable = false;
173170
uint32_t LoopInstCount = 0;
174-
175171
for (auto *BB : Loop->getBlocks()) {
176172
for (auto &Inst : *BB) {
177173
// Can't clone alloc_stack instructions whose dealloc_stack is outside
178174
// the loop.
179175
if (!Loop->canDuplicate(&Inst))
180176
return false;
181177

182-
if (!sinkProj.analyzeAddressProjections(&Inst)) {
183-
return false;
184-
}
185-
186178
ArraySemanticsCall ArrayPropsInst(&Inst, "array.props", true);
187179
if (!ArrayPropsInst)
188180
continue;
@@ -544,15 +536,10 @@ class RegionCloner : public SILCloner<RegionCloner> {
544536
for (auto *arg : origBB->getArguments())
545537
updateSSAForValue(origBB, arg, SSAUp);
546538

547-
SinkAddressProjections sinkProj;
548539
// Update outside used instruction values.
549540
for (auto &inst : *origBB) {
550-
for (auto result : inst.getResults()) {
551-
bool success = sinkProj.analyzeAddressProjections(&inst);
552-
assert(success);
553-
sinkProj.cloneProjections();
541+
for (auto result : inst.getResults())
554542
updateSSAForValue(origBB, result, SSAUp);
555-
}
556543
}
557544
}
558545
}

test/SILOptimizer/array_property_opt.sil

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -258,44 +258,3 @@ bb10: // Exit dominated by bb3
258258
bb11: // Non-exit dominated by bb1
259259
return %4 : $Builtin.Int1
260260
}
261-
262-
class Klass {
263-
}
264-
265-
struct WrapperStruct {
266-
var val: Klass
267-
}
268-
269-
sil @use_klass : $@convention(thin) (@in_guaranteed Klass) -> ()
270-
271-
sil @test_sink_address_proj : $@convention(thin) (@inout MyArray<MyClass>, @in_guaranteed WrapperStruct) -> () {
272-
bb0(%0 : $*MyArray<MyClass>, %1 : $*WrapperStruct):
273-
%3 = load %0 : $*MyArray<MyClass>
274-
br bb1
275-
276-
bb1:
277-
%2 = function_ref @arrayPropertyIsNative : $@convention(method) (@owned MyArray<MyClass>) -> Bool
278-
retain_value %3 : $MyArray<MyClass>
279-
%5 = apply %2(%3) : $@convention(method) (@owned MyArray<MyClass>) -> Bool
280-
%ele = struct_element_addr %1 : $*WrapperStruct, #WrapperStruct.val
281-
cond_br undef, bb5, bb2
282-
283-
bb2:
284-
%6 = integer_literal $Builtin.Int1, -1
285-
cond_br %6, bb3, bb4
286-
287-
bb3:
288-
br bb1
289-
290-
bb4:
291-
br bb6
292-
293-
bb5:
294-
%f = function_ref @use_klass : $@convention(thin) (@in_guaranteed Klass) -> ()
295-
%a = apply %f(%ele) : $@convention(thin) (@in_guaranteed Klass) -> ()
296-
br bb6
297-
298-
bb6:
299-
%t = tuple ()
300-
return %t : $()
301-
}

0 commit comments

Comments
 (0)