xref: /aosp_15_r20/external/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //- CFLAndersAliasAnalysis.cpp - Unification-based Alias Analysis ---*- C++-*-//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker // This file implements a CFL-based, summary-based alias analysis algorithm. It
11*9880d681SAndroid Build Coastguard Worker // differs from CFLSteensAliasAnalysis in its inclusion-based nature while
12*9880d681SAndroid Build Coastguard Worker // CFLSteensAliasAnalysis is unification-based. This pass has worse performance
13*9880d681SAndroid Build Coastguard Worker // than CFLSteensAliasAnalysis (the worst case complexity of
14*9880d681SAndroid Build Coastguard Worker // CFLAndersAliasAnalysis is cubic, while the worst case complexity of
15*9880d681SAndroid Build Coastguard Worker // CFLSteensAliasAnalysis is almost linear), but it is able to yield more
16*9880d681SAndroid Build Coastguard Worker // precise analysis result. The precision of this analysis is roughly the same
17*9880d681SAndroid Build Coastguard Worker // as that of an one level context-sensitive Andersen's algorithm.
18*9880d681SAndroid Build Coastguard Worker //
19*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
20*9880d681SAndroid Build Coastguard Worker 
21*9880d681SAndroid Build Coastguard Worker // N.B. AliasAnalysis as a whole is phrased as a FunctionPass at the moment, and
22*9880d681SAndroid Build Coastguard Worker // CFLAndersAA is interprocedural. This is *technically* A Bad Thing, because
23*9880d681SAndroid Build Coastguard Worker // FunctionPasses are only allowed to inspect the Function that they're being
24*9880d681SAndroid Build Coastguard Worker // run on. Realistically, this likely isn't a problem until we allow
25*9880d681SAndroid Build Coastguard Worker // FunctionPasses to run concurrently.
26*9880d681SAndroid Build Coastguard Worker 
27*9880d681SAndroid Build Coastguard Worker #include "llvm/Analysis/CFLAndersAliasAnalysis.h"
28*9880d681SAndroid Build Coastguard Worker #include "CFLGraph.h"
29*9880d681SAndroid Build Coastguard Worker #include "llvm/Pass.h"
30*9880d681SAndroid Build Coastguard Worker 
31*9880d681SAndroid Build Coastguard Worker using namespace llvm;
32*9880d681SAndroid Build Coastguard Worker using namespace llvm::cflaa;
33*9880d681SAndroid Build Coastguard Worker 
34*9880d681SAndroid Build Coastguard Worker #define DEBUG_TYPE "cfl-anders-aa"
35*9880d681SAndroid Build Coastguard Worker 
36*9880d681SAndroid Build Coastguard Worker CFLAndersAAResult::CFLAndersAAResult() = default;
37*9880d681SAndroid Build Coastguard Worker 
38*9880d681SAndroid Build Coastguard Worker char CFLAndersAA::PassID;
39*9880d681SAndroid Build Coastguard Worker 
run(Function & F,AnalysisManager<Function> & AM)40*9880d681SAndroid Build Coastguard Worker CFLAndersAAResult CFLAndersAA::run(Function &F, AnalysisManager<Function> &AM) {
41*9880d681SAndroid Build Coastguard Worker   return CFLAndersAAResult();
42*9880d681SAndroid Build Coastguard Worker }
43*9880d681SAndroid Build Coastguard Worker 
44*9880d681SAndroid Build Coastguard Worker char CFLAndersAAWrapperPass::ID = 0;
45*9880d681SAndroid Build Coastguard Worker INITIALIZE_PASS(CFLAndersAAWrapperPass, "cfl-anders-aa",
46*9880d681SAndroid Build Coastguard Worker                 "Inclusion-Based CFL Alias Analysis", false, true)
47*9880d681SAndroid Build Coastguard Worker 
createCFLAndersAAWrapperPass()48*9880d681SAndroid Build Coastguard Worker ImmutablePass *llvm::createCFLAndersAAWrapperPass() {
49*9880d681SAndroid Build Coastguard Worker   return new CFLAndersAAWrapperPass();
50*9880d681SAndroid Build Coastguard Worker }
51*9880d681SAndroid Build Coastguard Worker 
CFLAndersAAWrapperPass()52*9880d681SAndroid Build Coastguard Worker CFLAndersAAWrapperPass::CFLAndersAAWrapperPass() : ImmutablePass(ID) {
53*9880d681SAndroid Build Coastguard Worker   initializeCFLAndersAAWrapperPassPass(*PassRegistry::getPassRegistry());
54*9880d681SAndroid Build Coastguard Worker }
55*9880d681SAndroid Build Coastguard Worker 
initializePass()56*9880d681SAndroid Build Coastguard Worker void CFLAndersAAWrapperPass::initializePass() {}
57*9880d681SAndroid Build Coastguard Worker 
getAnalysisUsage(AnalysisUsage & AU) const58*9880d681SAndroid Build Coastguard Worker void CFLAndersAAWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
59*9880d681SAndroid Build Coastguard Worker   AU.setPreservesAll();
60*9880d681SAndroid Build Coastguard Worker }
61