Skip to content

Commit 609428c

Browse files
committed
IRGen: disable-llvm-optzns should disable the objc-arc-contract pass
Don't run the objc-arc-contract pass when disable-llvm-optzns is passed. In pipeline setups where the swift-frontend is called twice; - the first time to create bitcode - the second time to generate object code from the bitcode (using disable-llvm-optzns) we don't want to run the objc-arc-contract pass twice. rdar://91908312
1 parent 6aca5e5 commit 609428c

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

lib/IRGen/IRGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts,
364364
// rely on any other LLVM ARC transformations, but we do need ARC
365365
// contraction to add the objc_retainAutoreleasedReturnValue
366366
// assembly markers and remove clang.arc.used.
367-
if (Opts.shouldOptimize() && !DisableObjCARCContract)
367+
if (Opts.shouldOptimize() && !DisableObjCARCContract &&
368+
!Opts.DisableLLVMOptzns)
368369
ModulePasses.add(createObjCARCContractPass());
369370

370371
// Do it.

test/Frontend/embed-bitcode.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5050
; CHECK-COMPILER-OPT-NOT: argument unused
5151
; CHECK-COMPILER-OPT-DAG: Control Flow Optimizer
5252
; CHECK-COMPILER-OPT-DAG: Machine Common Subexpression Elimination
53-
; CHECK-COMPILER-OPT-DAG: ObjC ARC contraction
5453

5554
define i32 @f0() nounwind ssp {
5655
ret i32 0

test/IRGen/objc_arc_contract.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
// 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
66
// 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
7+
// RUN: %target-swift-frontend -import-objc-header %S/Inputs/StaticInline.h %s -emit-ir -disable-llvm-optzns -parse-as-library -O | %FileCheck --check-prefix=CHECK-WITHOUT-PASS %s
8+
// RUN: %target-swift-frontend -import-objc-header %S/Inputs/StaticInline.h %s -emit-bc -disable-llvm-optzns -parse-as-library -O -o %t/test1.bc && %llvm-dis -o - %t/test1.bc | %FileCheck --check-prefix=CHECK-WITHOUT-PASS %s
79

810
// 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
911
// 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

0 commit comments

Comments
 (0)