1 //===- LibCallAliasAnalysis.h - Implement AliasAnalysis for libcalls ------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the LibCallAliasAnalysis class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_ANALYSIS_LIBCALLALIASANALYSIS_H
15 #define LLVM_ANALYSIS_LIBCALLALIASANALYSIS_H
17 #include "llvm/Analysis/AliasAnalysis.h"
18 #include "llvm/IR/Module.h"
19 #include "llvm/Pass.h"
24 struct LibCallFunctionInfo;
26 /// Alias analysis driven from LibCallInfo.
27 struct LibCallAliasAnalysis : public FunctionPass, public AliasAnalysis {
28 static char ID; // Class identification
32 explicit LibCallAliasAnalysis(LibCallInfo *LC = nullptr)
33 : FunctionPass(ID), LCI(LC) {
34 initializeLibCallAliasAnalysisPass(*PassRegistry::getPassRegistry());
36 explicit LibCallAliasAnalysis(char &ID, LibCallInfo *LC)
37 : FunctionPass(ID), LCI(LC) {
38 initializeLibCallAliasAnalysisPass(*PassRegistry::getPassRegistry());
40 ~LibCallAliasAnalysis() override;
42 ModRefInfo getModRefInfo(ImmutableCallSite CS,
43 const MemoryLocation &Loc) override;
45 ModRefInfo getModRefInfo(ImmutableCallSite CS1,
46 ImmutableCallSite CS2) override {
47 // TODO: Could compare two direct calls against each other if we cared to.
48 return AliasAnalysis::getModRefInfo(CS1, CS2);
51 void getAnalysisUsage(AnalysisUsage &AU) const override;
53 bool runOnFunction(Function &F) override;
55 /// This method is used when a pass implements an analysis interface through
56 /// multiple inheritance.
58 /// If needed, it should override this to adjust the this pointer as needed
59 /// for the specified pass info.
60 void *getAdjustedAnalysisPointer(const void *PI) override {
61 if (PI == &AliasAnalysis::ID)
62 return (AliasAnalysis *)this;
67 ModRefInfo AnalyzeLibCallDetails(const LibCallFunctionInfo *FI,
69 const MemoryLocation &Loc);
72 /// Create an alias analysis pass that knows about the semantics of a set of
73 /// libcalls specified by LCI.
75 /// The newly constructed pass takes ownership of the pointer that is provided.
76 FunctionPass *createLibCallAliasAnalysisPass(LibCallInfo *LCI);
78 } // End of llvm namespace