LibCallAliasAnalysis.h revision a65d6a686e6ad865c61aec70c5bdfb30bf6f5b22
1626645c77be5420483052db48bbc45e4776305b8Chris Lattner//===- LibCallAliasAnalysis.h - Implement AliasAnalysis for libcalls ------===// 2626645c77be5420483052db48bbc45e4776305b8Chris Lattner// 3626645c77be5420483052db48bbc45e4776305b8Chris Lattner// The LLVM Compiler Infrastructure 4626645c77be5420483052db48bbc45e4776305b8Chris Lattner// 5626645c77be5420483052db48bbc45e4776305b8Chris Lattner// This file is distributed under the University of Illinois Open Source 6626645c77be5420483052db48bbc45e4776305b8Chris Lattner// License. See LICENSE.TXT for details. 7626645c77be5420483052db48bbc45e4776305b8Chris Lattner// 8626645c77be5420483052db48bbc45e4776305b8Chris Lattner//===----------------------------------------------------------------------===// 9626645c77be5420483052db48bbc45e4776305b8Chris Lattner// 10626645c77be5420483052db48bbc45e4776305b8Chris Lattner// This file defines the LibCallAliasAnalysis class. 11626645c77be5420483052db48bbc45e4776305b8Chris Lattner// 12626645c77be5420483052db48bbc45e4776305b8Chris Lattner//===----------------------------------------------------------------------===// 13626645c77be5420483052db48bbc45e4776305b8Chris Lattner 14626645c77be5420483052db48bbc45e4776305b8Chris Lattner#ifndef LLVM_ANALYSIS_LIBCALL_AA_H 15626645c77be5420483052db48bbc45e4776305b8Chris Lattner#define LLVM_ANALYSIS_LIBCALL_AA_H 16626645c77be5420483052db48bbc45e4776305b8Chris Lattner 17626645c77be5420483052db48bbc45e4776305b8Chris Lattner#include "llvm/Analysis/AliasAnalysis.h" 18626645c77be5420483052db48bbc45e4776305b8Chris Lattner#include "llvm/Pass.h" 19626645c77be5420483052db48bbc45e4776305b8Chris Lattner 20626645c77be5420483052db48bbc45e4776305b8Chris Lattnernamespace llvm { 21626645c77be5420483052db48bbc45e4776305b8Chris Lattner class LibCallInfo; 22e57b2dda547b551a1cd4dd0710fe5be2934426b6Bill Wendling struct LibCallFunctionInfo; 23626645c77be5420483052db48bbc45e4776305b8Chris Lattner 24626645c77be5420483052db48bbc45e4776305b8Chris Lattner /// LibCallAliasAnalysis - Alias analysis driven from LibCallInfo. 25e0223c296633ecaa5712c129a4cab7a0d6a3a9bfDuncan Sands struct LibCallAliasAnalysis : public FunctionPass, public AliasAnalysis { 26626645c77be5420483052db48bbc45e4776305b8Chris Lattner static char ID; // Class identification 27626645c77be5420483052db48bbc45e4776305b8Chris Lattner 28626645c77be5420483052db48bbc45e4776305b8Chris Lattner LibCallInfo *LCI; 29626645c77be5420483052db48bbc45e4776305b8Chris Lattner 30626645c77be5420483052db48bbc45e4776305b8Chris Lattner explicit LibCallAliasAnalysis(LibCallInfo *LC = 0) 31a65d6a686e6ad865c61aec70c5bdfb30bf6f5b22Owen Anderson : FunctionPass(ID), LCI(LC) { 32a65d6a686e6ad865c61aec70c5bdfb30bf6f5b22Owen Anderson initializeLibCallAliasAnalysisPass(*PassRegistry::getPassRegistry()); 33626645c77be5420483052db48bbc45e4776305b8Chris Lattner } 347569322765651f19eea0609fb082e6b267d5d2b5Owen Anderson explicit LibCallAliasAnalysis(char &ID, LibCallInfo *LC) 35a65d6a686e6ad865c61aec70c5bdfb30bf6f5b22Owen Anderson : FunctionPass(ID), LCI(LC) { 36a65d6a686e6ad865c61aec70c5bdfb30bf6f5b22Owen Anderson initializeLibCallAliasAnalysisPass(*PassRegistry::getPassRegistry()); 37626645c77be5420483052db48bbc45e4776305b8Chris Lattner } 38626645c77be5420483052db48bbc45e4776305b8Chris Lattner ~LibCallAliasAnalysis(); 39626645c77be5420483052db48bbc45e4776305b8Chris Lattner 40503e204470d7d49eacf973cef28ec26ff6641914Dan Gohman ModRefResult getModRefInfo(ImmutableCallSite CS, 41cfa06abaf7c5c3ef31e42e8b7e3a1592db4eaec4Dan Gohman const Location &Loc); 42626645c77be5420483052db48bbc45e4776305b8Chris Lattner 43503e204470d7d49eacf973cef28ec26ff6641914Dan Gohman ModRefResult getModRefInfo(ImmutableCallSite CS1, 44503e204470d7d49eacf973cef28ec26ff6641914Dan Gohman ImmutableCallSite CS2) { 45626645c77be5420483052db48bbc45e4776305b8Chris Lattner // TODO: Could compare two direct calls against each other if we cared to. 46503e204470d7d49eacf973cef28ec26ff6641914Dan Gohman return AliasAnalysis::getModRefInfo(CS1, CS2); 47626645c77be5420483052db48bbc45e4776305b8Chris Lattner } 48626645c77be5420483052db48bbc45e4776305b8Chris Lattner 49626645c77be5420483052db48bbc45e4776305b8Chris Lattner virtual void getAnalysisUsage(AnalysisUsage &AU) const; 50626645c77be5420483052db48bbc45e4776305b8Chris Lattner 51626645c77be5420483052db48bbc45e4776305b8Chris Lattner virtual bool runOnFunction(Function &F) { 52626645c77be5420483052db48bbc45e4776305b8Chris Lattner InitializeAliasAnalysis(this); // set up super class 53626645c77be5420483052db48bbc45e4776305b8Chris Lattner return false; 54626645c77be5420483052db48bbc45e4776305b8Chris Lattner } 55626645c77be5420483052db48bbc45e4776305b8Chris Lattner 5657b06fcca8ac04c10d176f99e65f03f71b05ad66Nick Lewycky /// getAdjustedAnalysisPointer - This method is used when a pass implements 5757b06fcca8ac04c10d176f99e65f03f71b05ad66Nick Lewycky /// an analysis interface through multiple inheritance. If needed, it 5857b06fcca8ac04c10d176f99e65f03f71b05ad66Nick Lewycky /// should override this to adjust the this pointer as needed for the 5957b06fcca8ac04c10d176f99e65f03f71b05ad66Nick Lewycky /// specified pass info. 607569322765651f19eea0609fb082e6b267d5d2b5Owen Anderson virtual void *getAdjustedAnalysisPointer(const void *PI) { 617569322765651f19eea0609fb082e6b267d5d2b5Owen Anderson if (PI == &AliasAnalysis::ID) 6257b06fcca8ac04c10d176f99e65f03f71b05ad66Nick Lewycky return (AliasAnalysis*)this; 6357b06fcca8ac04c10d176f99e65f03f71b05ad66Nick Lewycky return this; 6457b06fcca8ac04c10d176f99e65f03f71b05ad66Nick Lewycky } 6557b06fcca8ac04c10d176f99e65f03f71b05ad66Nick Lewycky 66626645c77be5420483052db48bbc45e4776305b8Chris Lattner private: 67626645c77be5420483052db48bbc45e4776305b8Chris Lattner ModRefResult AnalyzeLibCallDetails(const LibCallFunctionInfo *FI, 68503e204470d7d49eacf973cef28ec26ff6641914Dan Gohman ImmutableCallSite CS, 69cfa06abaf7c5c3ef31e42e8b7e3a1592db4eaec4Dan Gohman const Location &Loc); 70626645c77be5420483052db48bbc45e4776305b8Chris Lattner }; 71626645c77be5420483052db48bbc45e4776305b8Chris Lattner} // End of llvm namespace 72626645c77be5420483052db48bbc45e4776305b8Chris Lattner 73626645c77be5420483052db48bbc45e4776305b8Chris Lattner#endif 74