//===- ObjCARCAliasAnalysis.cpp - ObjC ARC Optimization -------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// \file /// This file defines a simple ARC-aware AliasAnalysis using special knowledge /// of Objective C to enhance other optimization passes which rely on the Alias /// Analysis infrastructure. /// /// WARNING: This file knows about certain library functions. It recognizes them /// by name, and hardwires knowledge of their semantics. /// /// WARNING: This file knows about how certain Objective-C library functions are /// used. Naive LLVM IR transformations which would otherwise be /// behavior-preserving may break these assumptions. /// /// TODO: Theoretically we could check for dependencies between objc_* calls /// and FMRB_OnlyAccessesArgumentPointees calls or other well-behaved calls. /// /// TODO: The calls here to AAResultBase member functions are all effectively /// no-ops that just return a conservative result. The original intent was to /// chain to another analysis for a recursive query, but this was lost in a /// refactor. These should instead be rephrased in terms of queries to AAQI.AAR. /// //===----------------------------------------------------------------------===// #include "llvm/Analysis/ObjCARCAliasAnalysis.h" #include "llvm/Analysis/ObjCARCAnalysisUtils.h" #include "llvm/Analysis/Passes.h" #include "llvm/IR/Function.h" #include "llvm/InitializePasses.h" #include "llvm/Pass.h" #define DEBUG_TYPE … usingnamespacellvm; usingnamespacellvm::objcarc; AliasResult ObjCARCAAResult::alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AAQueryInfo &AAQI, const Instruction *) { … } ModRefInfo ObjCARCAAResult::getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI, bool IgnoreLocals) { … } MemoryEffects ObjCARCAAResult::getMemoryEffects(const Function *F) { … } ModRefInfo ObjCARCAAResult::getModRefInfo(const CallBase *Call, const MemoryLocation &Loc, AAQueryInfo &AAQI) { … } AnalysisKey ObjCARCAA::Key; ObjCARCAAResult ObjCARCAA::run(Function &F, FunctionAnalysisManager &AM) { … }