Skip to content

Commit

Permalink
[LTO] enable ObjCARCContractPass only on optimized build
Browse files Browse the repository at this point in the history
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 <PeterRong@meta.com>
  • Loading branch information
DataCorrupted committed Aug 6, 2024
1 parent 69d67e6 commit 0c3cec5
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
; RUN: -o %t2.index \
; RUN: -r=%t.o,_use_arc,px

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

Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/CodeGen/TargetPassConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,8 @@ void TargetPassConfig::addCodeGenPrepare() {
void TargetPassConfig::addISelPrepare() {
addPreISel();

addPass(createObjCARCContractPass());
if (getOptLevel() != CodeGenOptLevel::None)
addPass(createObjCARCContractPass());

// Force codegen to run according to the callgraph.
if (requiresCodeGenSCCOrder())
Expand Down
10 changes: 0 additions & 10 deletions llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ class ObjCARCContract {
ARCRuntimeEntryPoints EP;
BundledRetainClaimRVs *BundledInsts = nullptr;

/// A flag indicating whether this optimization pass should run.
bool Run;

/// The inline asm string to insert between calls and RetainRV calls to make
/// the optimization work on targets which need it.
const MDString *RVInstMarker;
Expand Down Expand Up @@ -530,10 +527,6 @@ bool ObjCARCContract::tryToPeepholeInstruction(
//===----------------------------------------------------------------------===//

bool ObjCARCContract::init(Module &M) {
Run = ModuleHasARC(M);
if (!Run)
return false;

EP.init(&M);

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

if (!Run)
return false;

Changed = CFGChanged = false;
AA = A;
DT = D;
Expand Down
4 changes: 0 additions & 4 deletions llvm/test/CodeGen/AArch64/O0-pipeline.ll
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
; CHECK-NEXT: AArch64 Stack Tagging
; CHECK-NEXT: SME ABI Pass
; CHECK-NEXT: Exception handling preparation
; CHECK-NEXT: Dominator Tree Construction
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
; CHECK-NEXT: Function Alias Analysis Results
; CHECK-NEXT: ObjC ARC contraction
; CHECK-NEXT: Prepare callbr
; CHECK-NEXT: Safe Stack instrumentation pass
; CHECK-NEXT: Insert stack protectors
Expand Down
3 changes: 0 additions & 3 deletions llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@
; GCN-O0-NEXT: AMDGPU Rewrite Undef for PHI
; GCN-O0-NEXT: LCSSA Verifier
; GCN-O0-NEXT: Loop-Closed SSA Form Pass
; GCN-O0-NEXT: Basic Alias Analysis (stateless AA impl)
; GCN-O0-NEXT: Function Alias Analysis Results
; GCN-O0-NEXT: ObjC ARC contraction
; GCN-O0-NEXT: DummyCGSCCPass
; GCN-O0-NEXT: FunctionPass Manager
; GCN-O0-NEXT: Prepare callbr
Expand Down
4 changes: 0 additions & 4 deletions llvm/test/CodeGen/LoongArch/O0-pipeline.ll
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
; CHECK-NEXT: Scalarize Masked Memory Intrinsics
; CHECK-NEXT: Expand reduction intrinsics
; CHECK-NEXT: Exception handling preparation
; CHECK-NEXT: Dominator Tree Construction
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
; CHECK-NEXT: Function Alias Analysis Results
; CHECK-NEXT: ObjC ARC contraction
; CHECK-NEXT: Prepare callbr
; CHECK-NEXT: Safe Stack instrumentation pass
; CHECK-NEXT: Insert stack protectors
Expand Down
4 changes: 0 additions & 4 deletions llvm/test/CodeGen/PowerPC/O0-pipeline.ll
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
; CHECK-NEXT: Scalarize Masked Memory Intrinsics
; CHECK-NEXT: Expand reduction intrinsics
; CHECK-NEXT: Exception handling preparation
; CHECK-NEXT: Dominator Tree Construction
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
; CHECK-NEXT: Function Alias Analysis Results
; CHECK-NEXT: ObjC ARC contraction
; CHECK-NEXT: Prepare callbr
; CHECK-NEXT: Safe Stack instrumentation pass
; CHECK-NEXT: Insert stack protectors
Expand Down
4 changes: 0 additions & 4 deletions llvm/test/CodeGen/RISCV/O0-pipeline.ll
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
; CHECK-NEXT: Scalarize Masked Memory Intrinsics
; CHECK-NEXT: Expand reduction intrinsics
; CHECK-NEXT: Exception handling preparation
; CHECK-NEXT: Dominator Tree Construction
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
; CHECK-NEXT: Function Alias Analysis Results
; CHECK-NEXT: ObjC ARC contraction
; CHECK-NEXT: Prepare callbr
; CHECK-NEXT: Safe Stack instrumentation pass
; CHECK-NEXT: Insert stack protectors
Expand Down
4 changes: 0 additions & 4 deletions llvm/test/CodeGen/X86/O0-pipeline.ll
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
; CHECK-NEXT: Expand reduction intrinsics
; CHECK-NEXT: Expand indirectbr instructions
; CHECK-NEXT: Exception handling preparation
; CHECK-NEXT: Dominator Tree Construction
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
; CHECK-NEXT: Function Alias Analysis Results
; CHECK-NEXT: ObjC ARC contraction
; CHECK-NEXT: Prepare callbr
; CHECK-NEXT: Safe Stack instrumentation pass
; CHECK-NEXT: Insert stack protectors
Expand Down

0 comments on commit 0c3cec5

Please sign in to comment.