Chris Lattner | 5c49061 | 2008-06-05 23:45:18 +0000 | [diff] [blame] | 1 | //===- 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 | |
| 20 | namespace llvm { |
| 21 | class LibCallInfo; |
Bill Wendling | b877a1f | 2009-05-12 21:55:29 +0000 | [diff] [blame] | 22 | struct LibCallFunctionInfo; |
Chris Lattner | 5c49061 | 2008-06-05 23:45:18 +0000 | [diff] [blame] | 23 | |
| 24 | /// LibCallAliasAnalysis - Alias analysis driven from LibCallInfo. |
Duncan Sands | 59bf4fc | 2009-09-06 08:55:57 +0000 | [diff] [blame] | 25 | struct LibCallAliasAnalysis : public FunctionPass, public AliasAnalysis { |
Chris Lattner | 5c49061 | 2008-06-05 23:45:18 +0000 | [diff] [blame] | 26 | static char ID; // Class identification |
| 27 | |
| 28 | LibCallInfo *LCI; |
| 29 | |
| 30 | explicit LibCallAliasAnalysis(LibCallInfo *LC = 0) |
Owen Anderson | 90c579d | 2010-08-06 18:33:48 +0000 | [diff] [blame^] | 31 | : FunctionPass(ID), LCI(LC) { |
Chris Lattner | 5c49061 | 2008-06-05 23:45:18 +0000 | [diff] [blame] | 32 | } |
Owen Anderson | 90c579d | 2010-08-06 18:33:48 +0000 | [diff] [blame^] | 33 | explicit LibCallAliasAnalysis(char &ID, LibCallInfo *LC) |
Chris Lattner | 5c49061 | 2008-06-05 23:45:18 +0000 | [diff] [blame] | 34 | : FunctionPass(ID), LCI(LC) { |
| 35 | } |
| 36 | ~LibCallAliasAnalysis(); |
| 37 | |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame] | 38 | ModRefResult getModRefInfo(ImmutableCallSite CS, |
| 39 | const Value *P, unsigned Size); |
Chris Lattner | 5c49061 | 2008-06-05 23:45:18 +0000 | [diff] [blame] | 40 | |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame] | 41 | ModRefResult getModRefInfo(ImmutableCallSite CS1, |
| 42 | ImmutableCallSite CS2) { |
Chris Lattner | 5c49061 | 2008-06-05 23:45:18 +0000 | [diff] [blame] | 43 | // TODO: Could compare two direct calls against each other if we cared to. |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame] | 44 | return AliasAnalysis::getModRefInfo(CS1, CS2); |
Chris Lattner | 5c49061 | 2008-06-05 23:45:18 +0000 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | virtual void getAnalysisUsage(AnalysisUsage &AU) const; |
| 48 | |
| 49 | virtual bool runOnFunction(Function &F) { |
| 50 | InitializeAliasAnalysis(this); // set up super class |
| 51 | return false; |
| 52 | } |
| 53 | |
Nick Lewycky | b2bdf94 | 2010-07-30 20:19:09 +0000 | [diff] [blame] | 54 | /// getAdjustedAnalysisPointer - This method is used when a pass implements |
| 55 | /// an analysis interface through multiple inheritance. If needed, it |
| 56 | /// should override this to adjust the this pointer as needed for the |
| 57 | /// specified pass info. |
Owen Anderson | 90c579d | 2010-08-06 18:33:48 +0000 | [diff] [blame^] | 58 | virtual void *getAdjustedAnalysisPointer(const void *PI) { |
| 59 | if (PI == &AliasAnalysis::ID) |
Nick Lewycky | b2bdf94 | 2010-07-30 20:19:09 +0000 | [diff] [blame] | 60 | return (AliasAnalysis*)this; |
| 61 | return this; |
| 62 | } |
| 63 | |
Chris Lattner | 5c49061 | 2008-06-05 23:45:18 +0000 | [diff] [blame] | 64 | private: |
| 65 | ModRefResult AnalyzeLibCallDetails(const LibCallFunctionInfo *FI, |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame] | 66 | ImmutableCallSite CS, |
| 67 | const Value *P, unsigned Size); |
Chris Lattner | 5c49061 | 2008-06-05 23:45:18 +0000 | [diff] [blame] | 68 | }; |
| 69 | } // End of llvm namespace |
| 70 | |
| 71 | #endif |