Files
swift-mirror/test/LLVMPasses/loopinfo.swift
Meghana Gupta 2f37e10674 Rewrite UnsafeRawBufferPointer.Iterator.next to avoid non natural loop in SIL
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.
2024-09-05 15:35:39 -07:00

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
}