Skip to content

Commit 67cf7e0

Browse files
committed
[LTO] enable ObjCARCContractPass only on optimized build
Summary: \llvm#92331 tried to make `ObjCARCContractPass` by default, but it caused a regression on O0 builds and was reverted. This patch trys to bring that back by: 1. reverts the [revert](llvm@1579e9c). 2. `createObjCARCContractPass` only on optimized builds. Tests are updated to refelect the changes. Specifically, all `O0` tests should not include `ObjCARCContractPass` Signed-off-by: Peter Rong <[email protected]>
1 parent 1aaa05f commit 67cf7e0

File tree

9 files changed

+3
-35
lines changed

9 files changed

+3
-35
lines changed

clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
; RUN: -o %t2.index \
55
; RUN: -r=%t.o,_use_arc,px
66

7-
; RUN: %clang_cc1 -triple x86_64-apple-darwin \
7+
; RUN: %clang_cc1 -O2 -triple x86_64-apple-darwin \
88
; RUN: -emit-obj -fthinlto-index=%t.o.thinlto.bc \
99
; RUN: -o %t.native.o -x ir %t.o
1010

llvm/lib/CodeGen/TargetPassConfig.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,8 @@ void TargetPassConfig::addCodeGenPrepare() {
950950
void TargetPassConfig::addISelPrepare() {
951951
addPreISel();
952952

953-
addPass(createObjCARCContractPass());
953+
if (getOptLevel() != CodeGenOptLevel::None)
954+
addPass(createObjCARCContractPass());
954955

955956
// Force codegen to run according to the callgraph.
956957
if (requiresCodeGenSCCOrder())

llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ class ObjCARCContract {
7171
ARCRuntimeEntryPoints EP;
7272
BundledRetainClaimRVs *BundledInsts = nullptr;
7373

74-
/// A flag indicating whether this optimization pass should run.
75-
bool Run;
76-
7774
/// The inline asm string to insert between calls and RetainRV calls to make
7875
/// the optimization work on targets which need it.
7976
const MDString *RVInstMarker;
@@ -530,10 +527,6 @@ bool ObjCARCContract::tryToPeepholeInstruction(
530527
//===----------------------------------------------------------------------===//
531528

532529
bool ObjCARCContract::init(Module &M) {
533-
Run = ModuleHasARC(M);
534-
if (!Run)
535-
return false;
536-
537530
EP.init(&M);
538531

539532
// Initialize RVInstMarker.
@@ -546,9 +539,6 @@ bool ObjCARCContract::run(Function &F, AAResults *A, DominatorTree *D) {
546539
if (!EnableARCOpts)
547540
return false;
548541

549-
if (!Run)
550-
return false;
551-
552542
Changed = CFGChanged = false;
553543
AA = A;
554544
DT = D;

llvm/test/CodeGen/AArch64/O0-pipeline.ll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@
3232
; CHECK-NEXT: AArch64 Stack Tagging
3333
; CHECK-NEXT: SME ABI Pass
3434
; CHECK-NEXT: Exception handling preparation
35-
; CHECK-NEXT: Dominator Tree Construction
36-
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
37-
; CHECK-NEXT: Function Alias Analysis Results
38-
; CHECK-NEXT: ObjC ARC contraction
3935
; CHECK-NEXT: Prepare callbr
4036
; CHECK-NEXT: Safe Stack instrumentation pass
4137
; CHECK-NEXT: Insert stack protectors

llvm/test/CodeGen/AMDGPU/llc-pipeline.ll

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@
8989
; GCN-O0-NEXT: AMDGPU Rewrite Undef for PHI
9090
; GCN-O0-NEXT: LCSSA Verifier
9191
; GCN-O0-NEXT: Loop-Closed SSA Form Pass
92-
; GCN-O0-NEXT: Basic Alias Analysis (stateless AA impl)
93-
; GCN-O0-NEXT: Function Alias Analysis Results
94-
; GCN-O0-NEXT: ObjC ARC contraction
9592
; GCN-O0-NEXT: DummyCGSCCPass
9693
; GCN-O0-NEXT: FunctionPass Manager
9794
; GCN-O0-NEXT: Prepare callbr

llvm/test/CodeGen/LoongArch/O0-pipeline.ll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@
3232
; CHECK-NEXT: Scalarize Masked Memory Intrinsics
3333
; CHECK-NEXT: Expand reduction intrinsics
3434
; CHECK-NEXT: Exception handling preparation
35-
; CHECK-NEXT: Dominator Tree Construction
36-
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
37-
; CHECK-NEXT: Function Alias Analysis Results
38-
; CHECK-NEXT: ObjC ARC contraction
3935
; CHECK-NEXT: Prepare callbr
4036
; CHECK-NEXT: Safe Stack instrumentation pass
4137
; CHECK-NEXT: Insert stack protectors

llvm/test/CodeGen/PowerPC/O0-pipeline.ll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
; CHECK-NEXT: Scalarize Masked Memory Intrinsics
3232
; CHECK-NEXT: Expand reduction intrinsics
3333
; CHECK-NEXT: Exception handling preparation
34-
; CHECK-NEXT: Dominator Tree Construction
35-
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
36-
; CHECK-NEXT: Function Alias Analysis Results
37-
; CHECK-NEXT: ObjC ARC contraction
3834
; CHECK-NEXT: Prepare callbr
3935
; CHECK-NEXT: Safe Stack instrumentation pass
4036
; CHECK-NEXT: Insert stack protectors

llvm/test/CodeGen/RISCV/O0-pipeline.ll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@
3232
; CHECK-NEXT: Scalarize Masked Memory Intrinsics
3333
; CHECK-NEXT: Expand reduction intrinsics
3434
; CHECK-NEXT: Exception handling preparation
35-
; CHECK-NEXT: Dominator Tree Construction
36-
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
37-
; CHECK-NEXT: Function Alias Analysis Results
38-
; CHECK-NEXT: ObjC ARC contraction
3935
; CHECK-NEXT: Prepare callbr
4036
; CHECK-NEXT: Safe Stack instrumentation pass
4137
; CHECK-NEXT: Insert stack protectors

llvm/test/CodeGen/X86/O0-pipeline.ll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@
3333
; CHECK-NEXT: Expand reduction intrinsics
3434
; CHECK-NEXT: Expand indirectbr instructions
3535
; CHECK-NEXT: Exception handling preparation
36-
; CHECK-NEXT: Dominator Tree Construction
37-
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
38-
; CHECK-NEXT: Function Alias Analysis Results
39-
; CHECK-NEXT: ObjC ARC contraction
4036
; CHECK-NEXT: Prepare callbr
4137
; CHECK-NEXT: Safe Stack instrumentation pass
4238
; CHECK-NEXT: Insert stack protectors

0 commit comments

Comments
 (0)