LLVM API Documentation
00001 //===- LibCallAliasAnalysis.h - Implement AliasAnalysis for libcalls ------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the LibCallAliasAnalysis class. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_ANALYSIS_LIBCALLALIASANALYSIS_H 00015 #define LLVM_ANALYSIS_LIBCALLALIASANALYSIS_H 00016 00017 #include "llvm/Analysis/AliasAnalysis.h" 00018 #include "llvm/Pass.h" 00019 00020 namespace llvm { 00021 class LibCallInfo; 00022 struct LibCallFunctionInfo; 00023 00024 /// LibCallAliasAnalysis - Alias analysis driven from LibCallInfo. 00025 struct LibCallAliasAnalysis : public FunctionPass, public AliasAnalysis { 00026 static char ID; // Class identification 00027 00028 LibCallInfo *LCI; 00029 00030 explicit LibCallAliasAnalysis(LibCallInfo *LC = nullptr) 00031 : FunctionPass(ID), LCI(LC) { 00032 initializeLibCallAliasAnalysisPass(*PassRegistry::getPassRegistry()); 00033 } 00034 explicit LibCallAliasAnalysis(char &ID, LibCallInfo *LC) 00035 : FunctionPass(ID), LCI(LC) { 00036 initializeLibCallAliasAnalysisPass(*PassRegistry::getPassRegistry()); 00037 } 00038 ~LibCallAliasAnalysis(); 00039 00040 ModRefResult getModRefInfo(ImmutableCallSite CS, 00041 const Location &Loc) override; 00042 00043 ModRefResult getModRefInfo(ImmutableCallSite CS1, 00044 ImmutableCallSite CS2) override { 00045 // TODO: Could compare two direct calls against each other if we cared to. 00046 return AliasAnalysis::getModRefInfo(CS1, CS2); 00047 } 00048 00049 void getAnalysisUsage(AnalysisUsage &AU) const override; 00050 00051 bool runOnFunction(Function &F) override { 00052 InitializeAliasAnalysis(this); // set up super class 00053 return false; 00054 } 00055 00056 /// getAdjustedAnalysisPointer - This method is used when a pass implements 00057 /// an analysis interface through multiple inheritance. If needed, it 00058 /// should override this to adjust the this pointer as needed for the 00059 /// specified pass info. 00060 void *getAdjustedAnalysisPointer(const void *PI) override { 00061 if (PI == &AliasAnalysis::ID) 00062 return (AliasAnalysis*)this; 00063 return this; 00064 } 00065 00066 private: 00067 ModRefResult AnalyzeLibCallDetails(const LibCallFunctionInfo *FI, 00068 ImmutableCallSite CS, 00069 const Location &Loc); 00070 }; 00071 } // End of llvm namespace 00072 00073 #endif