mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The current implementation creates a non-natural loop and none of the SIL and LLVM loop passes will work for such loops. We have to find a way to fix this in SIL. Until then, rewrite so we get a natural loop in SIL.
25 lines
501 B
Swift
25 lines
501 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-frontend -emit-irgen -O -o %t/loopinfo.ll %s
|
|
// RUN: %swift-llvm-opt -passes='print<loops>' %t/loopinfo.ll 2>&1 | %FileCheck %s
|
|
|
|
// CHECK: Loop at depth 1 containing
|
|
public func iterate1(urbp: UnsafeRawBufferPointer) -> Int {
|
|
var s = 0
|
|
for v in urbp {
|
|
s += Int(v)
|
|
}
|
|
return s
|
|
}
|
|
|
|
// CHECK: Loop at depth 1 containing
|
|
public func iterate2(ubp: UnsafeBufferPointer<Int>) -> Int {
|
|
var s = 0
|
|
for v in ubp {
|
|
s += v
|
|
}
|
|
return s
|
|
}
|
|
|
|
|
|
|