blob: c256230fc5d5c50c6a1e97fd420b392fb1b7b227 [file] [log] [blame]
Chris Lattner5c490612008-06-05 23:45:18 +00001//===- LibCallAliasAnalysis.h - Implement AliasAnalysis for libcalls ------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the LibCallAliasAnalysis class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_ANALYSIS_LIBCALL_AA_H
15#define LLVM_ANALYSIS_LIBCALL_AA_H
16
17#include "llvm/Analysis/AliasAnalysis.h"
18#include "llvm/Pass.h"
19
20namespace llvm {
21 class LibCallInfo;
Bill Wendlingb877a1f2009-05-12 21:55:29 +000022 struct LibCallFunctionInfo;
Chris Lattner5c490612008-06-05 23:45:18 +000023
24 /// LibCallAliasAnalysis - Alias analysis driven from LibCallInfo.
Duncan Sands59bf4fc2009-09-06 08:55:57 +000025 struct LibCallAliasAnalysis : public FunctionPass, public AliasAnalysis {
Chris Lattner5c490612008-06-05 23:45:18 +000026 static char ID; // Class identification
27
28 LibCallInfo *LCI;
29
30 explicit LibCallAliasAnalysis(LibCallInfo *LC = 0)
31 : FunctionPass(&ID), LCI(LC) {
32 }
33 explicit LibCallAliasAnalysis(const void *ID, LibCallInfo *LC)
34 : FunctionPass(ID), LCI(LC) {
35 }
36 ~LibCallAliasAnalysis();
37
38 ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size);
39
40 ModRefResult getModRefInfo(CallSite CS1, CallSite CS2) {
41 // TODO: Could compare two direct calls against each other if we cared to.
42 return AliasAnalysis::getModRefInfo(CS1,CS2);
43 }
44
45 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
46
47 virtual bool runOnFunction(Function &F) {
48 InitializeAliasAnalysis(this); // set up super class
49 return false;
50 }
51
Nick Lewyckyb2bdf942010-07-30 20:19:09 +000052 /// getAdjustedAnalysisPointer - This method is used when a pass implements
53 /// an analysis interface through multiple inheritance. If needed, it
54 /// should override this to adjust the this pointer as needed for the
55 /// specified pass info.
56 virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
57 if (PI->isPassID(&AliasAnalysis::ID))
58 return (AliasAnalysis*)this;
59 return this;
60 }
61
Chris Lattner5c490612008-06-05 23:45:18 +000062 private:
63 ModRefResult AnalyzeLibCallDetails(const LibCallFunctionInfo *FI,
64 CallSite CS, Value *P, unsigned Size);
65 };
66} // End of llvm namespace
67
68#endif