https://github.com/DataCorrupted updated https://github.com/llvm/llvm-project/pull/101114
>From ebbba2b8a04fa063c7019566fb56227cb7196485 Mon Sep 17 00:00:00 2001 From: Peter Rong <peterr...@meta.com> Date: Mon, 29 Jul 2024 16:05:54 -0700 Subject: [PATCH 1/6] Reapply "Run ObjCContractPass in Default Codegen Pipeline (#92331)" This reverts commit 1579e9ca9ce17364963861517fecf13b00fe4d8a. --- clang/lib/CodeGen/BackendUtil.cpp | 6 --- .../thinlto-distributed-objc-contract-pass.ll | 19 +++++++++ lld/MachO/LTO.cpp | 3 -- .../llvm/Analysis/ObjCARCAnalysisUtils.h | 40 +++++++++---------- llvm/lib/CodeGen/TargetPassConfig.cpp | 3 ++ llvm/lib/LTO/LTOCodeGenerator.cpp | 4 -- llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 4 -- .../Transforms/ObjCARC/ObjCARCContract.cpp | 10 +++++ llvm/test/CodeGen/AArch64/O0-pipeline.ll | 4 ++ llvm/test/CodeGen/AArch64/O3-pipeline.ll | 4 ++ llvm/test/CodeGen/AMDGPU/llc-pipeline.ll | 19 +++++++++ llvm/test/CodeGen/ARM/O3-pipeline.ll | 4 ++ llvm/test/CodeGen/LoongArch/O0-pipeline.ll | 4 ++ llvm/test/CodeGen/LoongArch/opt-pipeline.ll | 4 ++ llvm/test/CodeGen/M68k/pipeline.ll | 4 ++ llvm/test/CodeGen/PowerPC/O0-pipeline.ll | 4 ++ llvm/test/CodeGen/PowerPC/O3-pipeline.ll | 4 ++ llvm/test/CodeGen/RISCV/O0-pipeline.ll | 4 ++ llvm/test/CodeGen/RISCV/O3-pipeline.ll | 4 ++ llvm/test/CodeGen/X86/O0-pipeline.ll | 4 ++ llvm/test/CodeGen/X86/opt-pipeline.ll | 4 ++ 21 files changed, 119 insertions(+), 37 deletions(-) create mode 100644 clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index e765bbf637a66..81e6702d5de66 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -588,12 +588,6 @@ bool EmitAssemblyHelper::AddEmitPasses(legacy::PassManager &CodeGenPasses, // this also adds codegenerator level optimization passes. CodeGenFileType CGFT = getCodeGenFileType(Action); - // Add ObjC ARC final-cleanup optimizations. This is done as part of the - // "codegen" passes so that it isn't run multiple times when there is - // inlining happening. - if (CodeGenOpts.OptimizationLevel > 0) - CodeGenPasses.add(createObjCARCContractPass()); - if (TM->addPassesToEmitFile(CodeGenPasses, OS, DwoOS, CGFT, /*DisableVerify=*/!CodeGenOpts.VerifyModule)) { Diags.Report(diag::err_fe_unable_to_interface_with_target); diff --git a/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll new file mode 100644 index 0000000000000..a2a7b62cb7f93 --- /dev/null +++ b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll @@ -0,0 +1,19 @@ +; RUN: opt -thinlto-bc -o %t.o %s + +; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \ +; RUN: -o %t2.index \ +; RUN: -r=%t.o,_use_arc,px + +; RUN: %clang_cc1 -triple x86_64-apple-darwin \ +; RUN: -emit-obj -fthinlto-index=%t.o.thinlto.bc \ +; RUN: -o %t.native.o -x ir %t.o + +target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-darwin" + +define void @use_arc(ptr %a, ptr %b) { + call void (...) @llvm.objc.clang.arc.use(ptr %a, ptr %b) nounwind + ret void +} + +declare void @llvm.objc.clang.arc.use(...) nounwind diff --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp index 7a9a9223a0322..6527cbb68f249 100644 --- a/lld/MachO/LTO.cpp +++ b/lld/MachO/LTO.cpp @@ -48,9 +48,6 @@ static lto::Config createConfig() { c.CPU = getCPUStr(); c.MAttrs = getMAttrs(); c.DiagHandler = diagnosticHandler; - c.PreCodeGenPassesHook = [](legacy::PassManager &pm) { - pm.add(createObjCARCContractPass()); - }; c.AlwaysEmitRegularLTOObj = !config->ltoObjPath.empty(); diff --git a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h index ccf859922e163..5ac6ad47f7799 100644 --- a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h +++ b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h @@ -41,26 +41,26 @@ extern bool EnableARCOpts; /// Test if the given module looks interesting to run ARC optimization /// on. inline bool ModuleHasARC(const Module &M) { - return - M.getNamedValue("llvm.objc.retain") || - M.getNamedValue("llvm.objc.release") || - M.getNamedValue("llvm.objc.autorelease") || - M.getNamedValue("llvm.objc.retainAutoreleasedReturnValue") || - M.getNamedValue("llvm.objc.unsafeClaimAutoreleasedReturnValue") || - M.getNamedValue("llvm.objc.retainBlock") || - M.getNamedValue("llvm.objc.autoreleaseReturnValue") || - M.getNamedValue("llvm.objc.autoreleasePoolPush") || - M.getNamedValue("llvm.objc.loadWeakRetained") || - M.getNamedValue("llvm.objc.loadWeak") || - M.getNamedValue("llvm.objc.destroyWeak") || - M.getNamedValue("llvm.objc.storeWeak") || - M.getNamedValue("llvm.objc.initWeak") || - M.getNamedValue("llvm.objc.moveWeak") || - M.getNamedValue("llvm.objc.copyWeak") || - M.getNamedValue("llvm.objc.retainedObject") || - M.getNamedValue("llvm.objc.unretainedObject") || - M.getNamedValue("llvm.objc.unretainedPointer") || - M.getNamedValue("llvm.objc.clang.arc.use"); + return M.getNamedValue("llvm.objc.retain") || + M.getNamedValue("llvm.objc.release") || + M.getNamedValue("llvm.objc.autorelease") || + M.getNamedValue("llvm.objc.retainAutoreleasedReturnValue") || + M.getNamedValue("llvm.objc.unsafeClaimAutoreleasedReturnValue") || + M.getNamedValue("llvm.objc.retainBlock") || + M.getNamedValue("llvm.objc.autoreleaseReturnValue") || + M.getNamedValue("llvm.objc.autoreleasePoolPush") || + M.getNamedValue("llvm.objc.loadWeakRetained") || + M.getNamedValue("llvm.objc.loadWeak") || + M.getNamedValue("llvm.objc.destroyWeak") || + M.getNamedValue("llvm.objc.storeWeak") || + M.getNamedValue("llvm.objc.initWeak") || + M.getNamedValue("llvm.objc.moveWeak") || + M.getNamedValue("llvm.objc.copyWeak") || + M.getNamedValue("llvm.objc.retainedObject") || + M.getNamedValue("llvm.objc.unretainedObject") || + M.getNamedValue("llvm.objc.unretainedPointer") || + M.getNamedValue("llvm.objc.clang.arc.noop.use") || + M.getNamedValue("llvm.objc.clang.arc.use"); } /// This is a wrapper around getUnderlyingObject which also knows how to diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp index 3a20b340d45f2..e90360b6dec7a 100644 --- a/llvm/lib/CodeGen/TargetPassConfig.cpp +++ b/llvm/lib/CodeGen/TargetPassConfig.cpp @@ -46,6 +46,7 @@ #include "llvm/Support/WithColor.h" #include "llvm/Target/CGPassBuilderOption.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/Transforms/ObjCARC.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils.h" #include <cassert> @@ -943,6 +944,8 @@ void TargetPassConfig::addCodeGenPrepare() { void TargetPassConfig::addISelPrepare() { addPreISel(); + addPass(createObjCARCContractPass()); + // Force codegen to run according to the callgraph. if (requiresCodeGenSCCOrder()) addPass(new DummyCGSCCPass); diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp index 34aacb660144f..a192392e04585 100644 --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -136,10 +136,6 @@ LTOCodeGenerator::LTOCodeGenerator(LLVMContext &Context) Config.CodeModel = std::nullopt; Config.StatsFile = LTOStatsFile; - Config.PreCodeGenPassesHook = [](legacy::PassManager &PM) { - PM.add(createObjCARCContractPass()); - }; - Config.RunCSIRInstr = LTORunCSIRInstr; Config.CSIRProfile = LTOCSIRProfile; } diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index 57c94e1988b79..b982df7c6e5d3 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -335,10 +335,6 @@ std::unique_ptr<MemoryBuffer> codegenModule(Module &TheModule, raw_svector_ostream OS(OutputBuffer); legacy::PassManager PM; - // If the bitcode files contain ARC code and were compiled with optimization, - // the ObjCARCContractPass must be run, so do it unconditionally here. - PM.add(createObjCARCContractPass()); - // Setup the codegen now. if (TM.addPassesToEmitFile(PM, OS, nullptr, CodeGenFileType::ObjectFile, /* DisableVerify */ true)) diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp index 0d0f5c72928ab..72ed57015e053 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp @@ -71,6 +71,9 @@ 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; @@ -527,6 +530,10 @@ bool ObjCARCContract::tryToPeepholeInstruction( //===----------------------------------------------------------------------===// bool ObjCARCContract::init(Module &M) { + Run = ModuleHasARC(M); + if (!Run) + return false; + EP.init(&M); // Initialize RVInstMarker. @@ -539,6 +546,9 @@ bool ObjCARCContract::run(Function &F, AAResults *A, DominatorTree *D) { if (!EnableARCOpts) return false; + if (!Run) + return false; + Changed = CFGChanged = false; AA = A; DT = D; diff --git a/llvm/test/CodeGen/AArch64/O0-pipeline.ll b/llvm/test/CodeGen/AArch64/O0-pipeline.ll index ba611493e1a76..d5a758a7b9883 100644 --- a/llvm/test/CodeGen/AArch64/O0-pipeline.ll +++ b/llvm/test/CodeGen/AArch64/O0-pipeline.ll @@ -30,6 +30,10 @@ ; 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 diff --git a/llvm/test/CodeGen/AArch64/O3-pipeline.ll b/llvm/test/CodeGen/AArch64/O3-pipeline.ll index 845634e8e9830..7135b4c123083 100644 --- a/llvm/test/CodeGen/AArch64/O3-pipeline.ll +++ b/llvm/test/CodeGen/AArch64/O3-pipeline.ll @@ -102,6 +102,10 @@ ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Merge internal globals +; 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 diff --git a/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll b/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll index ee7f9375bf5df..e115f7ff3164d 100644 --- a/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll +++ b/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll @@ -87,6 +87,9 @@ ; 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 @@ -279,6 +282,9 @@ ; GCN-O1-NEXT: AMDGPU Rewrite Undef for PHI ; GCN-O1-NEXT: LCSSA Verifier ; GCN-O1-NEXT: Loop-Closed SSA Form Pass +; GCN-O1-NEXT: Basic Alias Analysis (stateless AA impl) +; GCN-O1-NEXT: Function Alias Analysis Results +; GCN-O1-NEXT: ObjC ARC contraction ; GCN-O1-NEXT: DummyCGSCCPass ; GCN-O1-NEXT: FunctionPass Manager ; GCN-O1-NEXT: Prepare callbr @@ -571,6 +577,9 @@ ; GCN-O1-OPTS-NEXT: AMDGPU Rewrite Undef for PHI ; GCN-O1-OPTS-NEXT: LCSSA Verifier ; GCN-O1-OPTS-NEXT: Loop-Closed SSA Form Pass +; GCN-O1-OPTS-NEXT: Basic Alias Analysis (stateless AA impl) +; GCN-O1-OPTS-NEXT: Function Alias Analysis Results +; GCN-O1-OPTS-NEXT: ObjC ARC contraction ; GCN-O1-OPTS-NEXT: DummyCGSCCPass ; GCN-O1-OPTS-NEXT: FunctionPass Manager ; GCN-O1-OPTS-NEXT: Prepare callbr @@ -876,6 +885,11 @@ ; GCN-O2-NEXT: LCSSA Verifier ; GCN-O2-NEXT: Loop-Closed SSA Form Pass ; GCN-O2-NEXT: Analysis if a function is memory bound +; GCN-O2-NEXT: FunctionPass Manager +; GCN-O2-NEXT: Dominator Tree Construction +; GCN-O2-NEXT: Basic Alias Analysis (stateless AA impl) +; GCN-O2-NEXT: Function Alias Analysis Results +; GCN-O2-NEXT: ObjC ARC contraction ; GCN-O2-NEXT: DummyCGSCCPass ; GCN-O2-NEXT: FunctionPass Manager ; GCN-O2-NEXT: Prepare callbr @@ -1194,6 +1208,11 @@ ; GCN-O3-NEXT: LCSSA Verifier ; GCN-O3-NEXT: Loop-Closed SSA Form Pass ; GCN-O3-NEXT: Analysis if a function is memory bound +; GCN-O3-NEXT: FunctionPass Manager +; GCN-O3-NEXT: Dominator Tree Construction +; GCN-O3-NEXT: Basic Alias Analysis (stateless AA impl) +; GCN-O3-NEXT: Function Alias Analysis Results +; GCN-O3-NEXT: ObjC ARC contraction ; GCN-O3-NEXT: DummyCGSCCPass ; GCN-O3-NEXT: FunctionPass Manager ; GCN-O3-NEXT: Prepare callbr diff --git a/llvm/test/CodeGen/ARM/O3-pipeline.ll b/llvm/test/CodeGen/ARM/O3-pipeline.ll index e74e4f2ad3893..c4e0d16fff493 100644 --- a/llvm/test/CodeGen/ARM/O3-pipeline.ll +++ b/llvm/test/CodeGen/ARM/O3-pipeline.ll @@ -64,6 +64,10 @@ ; CHECK-NEXT: Transform predicated vector loops to use MVE tail predication ; CHECK-NEXT: A No-Op Barrier Pass ; CHECK-NEXT: FunctionPass Manager +; 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 diff --git a/llvm/test/CodeGen/LoongArch/O0-pipeline.ll b/llvm/test/CodeGen/LoongArch/O0-pipeline.ll index 38c1dbcb1075f..650a594dd4935 100644 --- a/llvm/test/CodeGen/LoongArch/O0-pipeline.ll +++ b/llvm/test/CodeGen/LoongArch/O0-pipeline.ll @@ -30,6 +30,10 @@ ; 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 diff --git a/llvm/test/CodeGen/LoongArch/opt-pipeline.ll b/llvm/test/CodeGen/LoongArch/opt-pipeline.ll index 391888a38daf6..4fe6f91e14351 100644 --- a/llvm/test/CodeGen/LoongArch/opt-pipeline.ll +++ b/llvm/test/CodeGen/LoongArch/opt-pipeline.ll @@ -70,10 +70,14 @@ ; LAXX-NEXT: CodeGen Prepare ; LAXX-NEXT: Dominator Tree Construction ; LAXX-NEXT: Exception handling preparation +; LAXX-NEXT: Basic Alias Analysis (stateless AA impl) +; LAXX-NEXT: Function Alias Analysis Results +; LAXX-NEXT: ObjC ARC contraction ; LAXX-NEXT: Prepare callbr ; LAXX-NEXT: Safe Stack instrumentation pass ; LAXX-NEXT: Insert stack protectors ; LAXX-NEXT: Module Verifier +; LAXX-NEXT: Dominator Tree Construction ; LAXX-NEXT: Basic Alias Analysis (stateless AA impl) ; LAXX-NEXT: Function Alias Analysis Results ; LAXX-NEXT: Natural Loop Information diff --git a/llvm/test/CodeGen/M68k/pipeline.ll b/llvm/test/CodeGen/M68k/pipeline.ll index 6aa66d09aa78b..95cc1d57b6865 100644 --- a/llvm/test/CodeGen/M68k/pipeline.ll +++ b/llvm/test/CodeGen/M68k/pipeline.ll @@ -40,10 +40,14 @@ ; CHECK-NEXT: CodeGen Prepare ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Exception handling preparation +; 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 ; CHECK-NEXT: Module Verifier +; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) ; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Natural Loop Information diff --git a/llvm/test/CodeGen/PowerPC/O0-pipeline.ll b/llvm/test/CodeGen/PowerPC/O0-pipeline.ll index 70b421f8c0c5f..25d45f25ecbde 100644 --- a/llvm/test/CodeGen/PowerPC/O0-pipeline.ll +++ b/llvm/test/CodeGen/PowerPC/O0-pipeline.ll @@ -29,6 +29,10 @@ ; 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 diff --git a/llvm/test/CodeGen/PowerPC/O3-pipeline.ll b/llvm/test/CodeGen/PowerPC/O3-pipeline.ll index f4f492782eb65..765c97abf0770 100644 --- a/llvm/test/CodeGen/PowerPC/O3-pipeline.ll +++ b/llvm/test/CodeGen/PowerPC/O3-pipeline.ll @@ -81,10 +81,14 @@ ; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: Optimization Remark Emitter ; CHECK-NEXT: Hardware Loop Insertion +; 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 ; CHECK-NEXT: Module Verifier +; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) ; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Natural Loop Information diff --git a/llvm/test/CodeGen/RISCV/O0-pipeline.ll b/llvm/test/CodeGen/RISCV/O0-pipeline.ll index 9be03d557bd8d..5f0878eba6108 100644 --- a/llvm/test/CodeGen/RISCV/O0-pipeline.ll +++ b/llvm/test/CodeGen/RISCV/O0-pipeline.ll @@ -30,6 +30,10 @@ ; 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 diff --git a/llvm/test/CodeGen/RISCV/O3-pipeline.ll b/llvm/test/CodeGen/RISCV/O3-pipeline.ll index 7bad290bf313c..151dc7dd4f781 100644 --- a/llvm/test/CodeGen/RISCV/O3-pipeline.ll +++ b/llvm/test/CodeGen/RISCV/O3-pipeline.ll @@ -73,6 +73,10 @@ ; CHECK-NEXT: Exception handling preparation ; CHECK-NEXT: A No-Op Barrier Pass ; CHECK-NEXT: FunctionPass Manager +; 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 diff --git a/llvm/test/CodeGen/X86/O0-pipeline.ll b/llvm/test/CodeGen/X86/O0-pipeline.ll index 98b86384b8443..9ecf8f16e7f4c 100644 --- a/llvm/test/CodeGen/X86/O0-pipeline.ll +++ b/llvm/test/CodeGen/X86/O0-pipeline.ll @@ -31,6 +31,10 @@ ; 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 diff --git a/llvm/test/CodeGen/X86/opt-pipeline.ll b/llvm/test/CodeGen/X86/opt-pipeline.ll index 6fcc1ed068f43..63c9fefaa6d06 100644 --- a/llvm/test/CodeGen/X86/opt-pipeline.ll +++ b/llvm/test/CodeGen/X86/opt-pipeline.ll @@ -71,10 +71,14 @@ ; CHECK-NEXT: CodeGen Prepare ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Exception handling preparation +; 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 ; CHECK-NEXT: Module Verifier +; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) ; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Natural Loop Information >From a1604defd3e3bec4882eabc918d96fb225d8d598 Mon Sep 17 00:00:00 2001 From: Peter Rong <peterr...@meta.com> Date: Mon, 29 Jul 2024 20:19:15 -0700 Subject: [PATCH 2/6] [LTO] enable `ObjCARCContractPass` only on optimized build Summary: \#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](https://github.com/llvm/llvm-project/commit/1579e9ca9ce17364963861517fecf13b00fe4d8a). 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 <peterr...@meta.com> --- .../CodeGen/thinlto-distributed-objc-contract-pass.ll | 2 +- llvm/lib/CodeGen/TargetPassConfig.cpp | 3 ++- llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp | 10 ---------- llvm/test/CodeGen/AArch64/O0-pipeline.ll | 4 ---- llvm/test/CodeGen/AMDGPU/llc-pipeline.ll | 3 --- llvm/test/CodeGen/LoongArch/O0-pipeline.ll | 4 ---- llvm/test/CodeGen/PowerPC/O0-pipeline.ll | 4 ---- llvm/test/CodeGen/RISCV/O0-pipeline.ll | 4 ---- llvm/test/CodeGen/X86/O0-pipeline.ll | 4 ---- 9 files changed, 3 insertions(+), 35 deletions(-) diff --git a/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll index a2a7b62cb7f93..e0256da314306 100644 --- a/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll +++ b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll @@ -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 diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp index e90360b6dec7a..79e240d62a17d 100644 --- a/llvm/lib/CodeGen/TargetPassConfig.cpp +++ b/llvm/lib/CodeGen/TargetPassConfig.cpp @@ -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()) diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp index 72ed57015e053..0d0f5c72928ab 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp @@ -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; @@ -530,10 +527,6 @@ bool ObjCARCContract::tryToPeepholeInstruction( //===----------------------------------------------------------------------===// bool ObjCARCContract::init(Module &M) { - Run = ModuleHasARC(M); - if (!Run) - return false; - EP.init(&M); // Initialize RVInstMarker. @@ -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; diff --git a/llvm/test/CodeGen/AArch64/O0-pipeline.ll b/llvm/test/CodeGen/AArch64/O0-pipeline.ll index d5a758a7b9883..ba611493e1a76 100644 --- a/llvm/test/CodeGen/AArch64/O0-pipeline.ll +++ b/llvm/test/CodeGen/AArch64/O0-pipeline.ll @@ -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 diff --git a/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll b/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll index e115f7ff3164d..c896bfe925ed8 100644 --- a/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll +++ b/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll @@ -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 diff --git a/llvm/test/CodeGen/LoongArch/O0-pipeline.ll b/llvm/test/CodeGen/LoongArch/O0-pipeline.ll index 650a594dd4935..38c1dbcb1075f 100644 --- a/llvm/test/CodeGen/LoongArch/O0-pipeline.ll +++ b/llvm/test/CodeGen/LoongArch/O0-pipeline.ll @@ -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 diff --git a/llvm/test/CodeGen/PowerPC/O0-pipeline.ll b/llvm/test/CodeGen/PowerPC/O0-pipeline.ll index 25d45f25ecbde..70b421f8c0c5f 100644 --- a/llvm/test/CodeGen/PowerPC/O0-pipeline.ll +++ b/llvm/test/CodeGen/PowerPC/O0-pipeline.ll @@ -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 diff --git a/llvm/test/CodeGen/RISCV/O0-pipeline.ll b/llvm/test/CodeGen/RISCV/O0-pipeline.ll index 5f0878eba6108..9be03d557bd8d 100644 --- a/llvm/test/CodeGen/RISCV/O0-pipeline.ll +++ b/llvm/test/CodeGen/RISCV/O0-pipeline.ll @@ -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 diff --git a/llvm/test/CodeGen/X86/O0-pipeline.ll b/llvm/test/CodeGen/X86/O0-pipeline.ll index 9ecf8f16e7f4c..98b86384b8443 100644 --- a/llvm/test/CodeGen/X86/O0-pipeline.ll +++ b/llvm/test/CodeGen/X86/O0-pipeline.ll @@ -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 >From 4fc7867c4502d7c049817d98c009cd095fc016aa Mon Sep 17 00:00:00 2001 From: Peter Rong <peterr...@meta.com> Date: Mon, 29 Jul 2024 22:15:19 -0700 Subject: [PATCH 3/6] Revert unnecessary format changes in ObjCARCAnalysisUtils.h Signed-off-by: Peter Rong <peterr...@meta.com> --- .../llvm/Analysis/ObjCARCAnalysisUtils.h | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h index 5ac6ad47f7799..ccf859922e163 100644 --- a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h +++ b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h @@ -41,26 +41,26 @@ extern bool EnableARCOpts; /// Test if the given module looks interesting to run ARC optimization /// on. inline bool ModuleHasARC(const Module &M) { - return M.getNamedValue("llvm.objc.retain") || - M.getNamedValue("llvm.objc.release") || - M.getNamedValue("llvm.objc.autorelease") || - M.getNamedValue("llvm.objc.retainAutoreleasedReturnValue") || - M.getNamedValue("llvm.objc.unsafeClaimAutoreleasedReturnValue") || - M.getNamedValue("llvm.objc.retainBlock") || - M.getNamedValue("llvm.objc.autoreleaseReturnValue") || - M.getNamedValue("llvm.objc.autoreleasePoolPush") || - M.getNamedValue("llvm.objc.loadWeakRetained") || - M.getNamedValue("llvm.objc.loadWeak") || - M.getNamedValue("llvm.objc.destroyWeak") || - M.getNamedValue("llvm.objc.storeWeak") || - M.getNamedValue("llvm.objc.initWeak") || - M.getNamedValue("llvm.objc.moveWeak") || - M.getNamedValue("llvm.objc.copyWeak") || - M.getNamedValue("llvm.objc.retainedObject") || - M.getNamedValue("llvm.objc.unretainedObject") || - M.getNamedValue("llvm.objc.unretainedPointer") || - M.getNamedValue("llvm.objc.clang.arc.noop.use") || - M.getNamedValue("llvm.objc.clang.arc.use"); + return + M.getNamedValue("llvm.objc.retain") || + M.getNamedValue("llvm.objc.release") || + M.getNamedValue("llvm.objc.autorelease") || + M.getNamedValue("llvm.objc.retainAutoreleasedReturnValue") || + M.getNamedValue("llvm.objc.unsafeClaimAutoreleasedReturnValue") || + M.getNamedValue("llvm.objc.retainBlock") || + M.getNamedValue("llvm.objc.autoreleaseReturnValue") || + M.getNamedValue("llvm.objc.autoreleasePoolPush") || + M.getNamedValue("llvm.objc.loadWeakRetained") || + M.getNamedValue("llvm.objc.loadWeak") || + M.getNamedValue("llvm.objc.destroyWeak") || + M.getNamedValue("llvm.objc.storeWeak") || + M.getNamedValue("llvm.objc.initWeak") || + M.getNamedValue("llvm.objc.moveWeak") || + M.getNamedValue("llvm.objc.copyWeak") || + M.getNamedValue("llvm.objc.retainedObject") || + M.getNamedValue("llvm.objc.unretainedObject") || + M.getNamedValue("llvm.objc.unretainedPointer") || + M.getNamedValue("llvm.objc.clang.arc.use"); } /// This is a wrapper around getUnderlyingObject which also knows how to >From a45b3b9cc123791b194b8aad60adb90891fc8587 Mon Sep 17 00:00:00 2001 From: Peter Rong <peterr...@meta.com> Date: Mon, 5 Aug 2024 12:11:01 -0700 Subject: [PATCH 4/6] Add `ModuleHasARC` check back to skip the pass on non objc modules. Signed-off-by: Peter Rong <peterr...@meta.com> --- .../llvm/Analysis/ObjCARCAnalysisUtils.h | 40 +++++++++---------- .../Transforms/ObjCARC/ObjCARCContract.cpp | 10 +++++ 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h index ccf859922e163..5ac6ad47f7799 100644 --- a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h +++ b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h @@ -41,26 +41,26 @@ extern bool EnableARCOpts; /// Test if the given module looks interesting to run ARC optimization /// on. inline bool ModuleHasARC(const Module &M) { - return - M.getNamedValue("llvm.objc.retain") || - M.getNamedValue("llvm.objc.release") || - M.getNamedValue("llvm.objc.autorelease") || - M.getNamedValue("llvm.objc.retainAutoreleasedReturnValue") || - M.getNamedValue("llvm.objc.unsafeClaimAutoreleasedReturnValue") || - M.getNamedValue("llvm.objc.retainBlock") || - M.getNamedValue("llvm.objc.autoreleaseReturnValue") || - M.getNamedValue("llvm.objc.autoreleasePoolPush") || - M.getNamedValue("llvm.objc.loadWeakRetained") || - M.getNamedValue("llvm.objc.loadWeak") || - M.getNamedValue("llvm.objc.destroyWeak") || - M.getNamedValue("llvm.objc.storeWeak") || - M.getNamedValue("llvm.objc.initWeak") || - M.getNamedValue("llvm.objc.moveWeak") || - M.getNamedValue("llvm.objc.copyWeak") || - M.getNamedValue("llvm.objc.retainedObject") || - M.getNamedValue("llvm.objc.unretainedObject") || - M.getNamedValue("llvm.objc.unretainedPointer") || - M.getNamedValue("llvm.objc.clang.arc.use"); + return M.getNamedValue("llvm.objc.retain") || + M.getNamedValue("llvm.objc.release") || + M.getNamedValue("llvm.objc.autorelease") || + M.getNamedValue("llvm.objc.retainAutoreleasedReturnValue") || + M.getNamedValue("llvm.objc.unsafeClaimAutoreleasedReturnValue") || + M.getNamedValue("llvm.objc.retainBlock") || + M.getNamedValue("llvm.objc.autoreleaseReturnValue") || + M.getNamedValue("llvm.objc.autoreleasePoolPush") || + M.getNamedValue("llvm.objc.loadWeakRetained") || + M.getNamedValue("llvm.objc.loadWeak") || + M.getNamedValue("llvm.objc.destroyWeak") || + M.getNamedValue("llvm.objc.storeWeak") || + M.getNamedValue("llvm.objc.initWeak") || + M.getNamedValue("llvm.objc.moveWeak") || + M.getNamedValue("llvm.objc.copyWeak") || + M.getNamedValue("llvm.objc.retainedObject") || + M.getNamedValue("llvm.objc.unretainedObject") || + M.getNamedValue("llvm.objc.unretainedPointer") || + M.getNamedValue("llvm.objc.clang.arc.noop.use") || + M.getNamedValue("llvm.objc.clang.arc.use"); } /// This is a wrapper around getUnderlyingObject which also knows how to diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp index 0d0f5c72928ab..248b481958303 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp @@ -71,6 +71,9 @@ 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; @@ -527,6 +530,10 @@ bool ObjCARCContract::tryToPeepholeInstruction( //===----------------------------------------------------------------------===// bool ObjCARCContract::init(Module &M) { + Run = ModuleHasARC(M); + if (!Run) + return false; + EP.init(&M); // Initialize RVInstMarker. @@ -536,6 +543,9 @@ bool ObjCARCContract::init(Module &M) { } bool ObjCARCContract::run(Function &F, AAResults *A, DominatorTree *D) { + if (!Run) + return false; + if (!EnableARCOpts) return false; >From 34e6238e64f0a1e164a53f65888a177785cde727 Mon Sep 17 00:00:00 2001 From: Peter Rong <peterr...@meta.com> Date: Tue, 6 Aug 2024 10:21:22 -0700 Subject: [PATCH 5/6] Indicate that DT is preserved in ObjCARCContractPass Tests have been changed to show that we don't have as much DT construction as before. --- llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp | 1 + llvm/test/CodeGen/AArch64/O3-pipeline.ll | 1 - llvm/test/CodeGen/ARM/O3-pipeline.ll | 1 - llvm/test/CodeGen/LoongArch/opt-pipeline.ll | 1 - llvm/test/CodeGen/M68k/pipeline.ll | 1 - llvm/test/CodeGen/PowerPC/O3-pipeline.ll | 1 - llvm/test/CodeGen/RISCV/O3-pipeline.ll | 3 +-- llvm/test/CodeGen/X86/opt-pipeline.ll | 1 - 8 files changed, 2 insertions(+), 8 deletions(-) diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp index 248b481958303..7db656d4e656b 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp @@ -740,6 +740,7 @@ INITIALIZE_PASS_END(ObjCARCContractLegacyPass, "objc-arc-contract", void ObjCARCContractLegacyPass::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<AAResultsWrapperPass>(); AU.addRequired<DominatorTreeWrapperPass>(); + AU.addPreserved<DominatorTreeWrapperPass>(); } Pass *llvm::createObjCARCContractPass() { diff --git a/llvm/test/CodeGen/AArch64/O3-pipeline.ll b/llvm/test/CodeGen/AArch64/O3-pipeline.ll index 7135b4c123083..72a888bde5ebb 100644 --- a/llvm/test/CodeGen/AArch64/O3-pipeline.ll +++ b/llvm/test/CodeGen/AArch64/O3-pipeline.ll @@ -110,7 +110,6 @@ ; CHECK-NEXT: Safe Stack instrumentation pass ; CHECK-NEXT: Insert stack protectors ; CHECK-NEXT: Module Verifier -; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) ; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Natural Loop Information diff --git a/llvm/test/CodeGen/ARM/O3-pipeline.ll b/llvm/test/CodeGen/ARM/O3-pipeline.ll index c4e0d16fff493..9b983d96f7933 100644 --- a/llvm/test/CodeGen/ARM/O3-pipeline.ll +++ b/llvm/test/CodeGen/ARM/O3-pipeline.ll @@ -72,7 +72,6 @@ ; CHECK-NEXT: Safe Stack instrumentation pass ; CHECK-NEXT: Insert stack protectors ; CHECK-NEXT: Module Verifier -; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) ; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Natural Loop Information diff --git a/llvm/test/CodeGen/LoongArch/opt-pipeline.ll b/llvm/test/CodeGen/LoongArch/opt-pipeline.ll index 4fe6f91e14351..82c4e3f6372ac 100644 --- a/llvm/test/CodeGen/LoongArch/opt-pipeline.ll +++ b/llvm/test/CodeGen/LoongArch/opt-pipeline.ll @@ -77,7 +77,6 @@ ; LAXX-NEXT: Safe Stack instrumentation pass ; LAXX-NEXT: Insert stack protectors ; LAXX-NEXT: Module Verifier -; LAXX-NEXT: Dominator Tree Construction ; LAXX-NEXT: Basic Alias Analysis (stateless AA impl) ; LAXX-NEXT: Function Alias Analysis Results ; LAXX-NEXT: Natural Loop Information diff --git a/llvm/test/CodeGen/M68k/pipeline.ll b/llvm/test/CodeGen/M68k/pipeline.ll index 95cc1d57b6865..76d72f5a50420 100644 --- a/llvm/test/CodeGen/M68k/pipeline.ll +++ b/llvm/test/CodeGen/M68k/pipeline.ll @@ -47,7 +47,6 @@ ; CHECK-NEXT: Safe Stack instrumentation pass ; CHECK-NEXT: Insert stack protectors ; CHECK-NEXT: Module Verifier -; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) ; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Natural Loop Information diff --git a/llvm/test/CodeGen/PowerPC/O3-pipeline.ll b/llvm/test/CodeGen/PowerPC/O3-pipeline.ll index 765c97abf0770..60d42704ca795 100644 --- a/llvm/test/CodeGen/PowerPC/O3-pipeline.ll +++ b/llvm/test/CodeGen/PowerPC/O3-pipeline.ll @@ -88,7 +88,6 @@ ; CHECK-NEXT: Safe Stack instrumentation pass ; CHECK-NEXT: Insert stack protectors ; CHECK-NEXT: Module Verifier -; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) ; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Natural Loop Information diff --git a/llvm/test/CodeGen/RISCV/O3-pipeline.ll b/llvm/test/CodeGen/RISCV/O3-pipeline.ll index 151dc7dd4f781..d5a595c388b2f 100644 --- a/llvm/test/CodeGen/RISCV/O3-pipeline.ll +++ b/llvm/test/CodeGen/RISCV/O3-pipeline.ll @@ -81,7 +81,6 @@ ; CHECK-NEXT: Safe Stack instrumentation pass ; CHECK-NEXT: Insert stack protectors ; CHECK-NEXT: Module Verifier -; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) ; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Natural Loop Information @@ -197,7 +196,7 @@ ; CHECK-NEXT: Machine Optimization Remark Emitter ; CHECK-NEXT: Stack Frame Layout Analysis ; CHECK-NEXT: RISC-V Zcmp move merging pass -; CHECK-NEXT: RISC-V Zcmp Push/Pop optimization pass +; CHECK-NEXT: RISC-V Zcmp Push/Pop optimization pass ; CHECK-NEXT: RISC-V Indirect Branch Tracking ; CHECK-NEXT: RISC-V pseudo instruction expansion pass ; CHECK-NEXT: RISC-V atomic pseudo instruction expansion pass diff --git a/llvm/test/CodeGen/X86/opt-pipeline.ll b/llvm/test/CodeGen/X86/opt-pipeline.ll index 63c9fefaa6d06..12c16a03b134c 100644 --- a/llvm/test/CodeGen/X86/opt-pipeline.ll +++ b/llvm/test/CodeGen/X86/opt-pipeline.ll @@ -78,7 +78,6 @@ ; CHECK-NEXT: Safe Stack instrumentation pass ; CHECK-NEXT: Insert stack protectors ; CHECK-NEXT: Module Verifier -; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) ; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Natural Loop Information >From c9c15bb0a25d7460d815a44e9c33e283cad40aa9 Mon Sep 17 00:00:00 2001 From: Peter Rong <peterr...@meta.com> Date: Tue, 6 Aug 2024 12:30:32 -0700 Subject: [PATCH 6/6] preserving AA analysis as well Signed-off-by: Peter Rong <peterr...@meta.com> --- llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp index 7db656d4e656b..e0f43e31288a3 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp @@ -31,6 +31,7 @@ #include "ProvenanceAnalysis.h" #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/AliasAnalysis.h" +#include "llvm/Analysis/BasicAliasAnalysis.h" #include "llvm/Analysis/ObjCARCUtil.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/EHPersonalities.h" @@ -740,6 +741,8 @@ INITIALIZE_PASS_END(ObjCARCContractLegacyPass, "objc-arc-contract", void ObjCARCContractLegacyPass::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<AAResultsWrapperPass>(); AU.addRequired<DominatorTreeWrapperPass>(); + AU.addPreserved<AAResultsWrapperPass>(); + AU.addPreserved<BasicAAWrapperPass>(); AU.addPreserved<DominatorTreeWrapperPass>(); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits