Files
swift-mirror/test/IRGen/objc_arc_contract.swift
Michael Gottesman 723c6212f2 Run ObjCARCContract when optimizing no matter the IRGenOutputKind.
Previously, we were just running ObjCARCContract when codegening. This is out of
character with the rest of the LLVM passes in Swift, namely that after these
have run, an IR pass no longer contains any compiler intrinsics. This can be
seen by SwiftARCContract running in the -O pipeline.

This commit harmonizes the behavior here.

For testing purposes, I added a flag that disables the running of
ObjCARCContract for testing purposes.

rdar://34824507
2017-10-06 08:59:58 -07:00

29 lines
1.3 KiB
Swift

// Make sure that we run objc arc contract when emitting ir or bc with optimization enabled.
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -import-objc-header %S/Inputs/StaticInline.h %s -emit-ir -Xllvm -disable-objc-arc-contract -parse-as-library -O | %FileCheck --check-prefix=CHECK-WITHOUT-PASS %s
// RUN: %target-swift-frontend -import-objc-header %S/Inputs/StaticInline.h %s -emit-bc -Xllvm -disable-objc-arc-contract -parse-as-library -O -o %t/test1.bc && %llvm-dis -o - %t/test1.bc | %FileCheck --check-prefix=CHECK-WITHOUT-PASS %s
// RUN: %target-swift-frontend -import-objc-header %S/Inputs/StaticInline.h %s -emit-ir -parse-as-library -O | %FileCheck --check-prefix=CHECK-WITH-PASS %s
// RUN: %target-swift-frontend -import-objc-header %S/Inputs/StaticInline.h %s -emit-bc -parse-as-library -O -o %t/test2.bc && %llvm-dis -o - %t/test2.bc | %FileCheck --check-prefix=CHECK-WITH-PASS %s
// REQUIRES: objc_interop
// REQUIRES: asserts
// CHECK-WITHOUT-PASS: call void (...) @clang.arc.use
// CHECK-WITH-PASS-NOT: call void (...) @clang.arc.use
import Foundation
@inline(never)
public func foo() throws {
let x: FileManager! = nil
let y = URL(string: "http://swift.org")
let z: URL! = nil
let w: String = "foo"
var e: NSError? = nil
test(x, y, z, w, .usingNewMetadataOnly, &e)
}