Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 1 | //===- DataStructureAA.cpp - Data Structure Based Alias Analysis ----------===// |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 2 | // |
John Criswell | b576c94 | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 7 | // |
John Criswell | b576c94 | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 9 | // |
| 10 | // This pass uses the top-down data structure graphs to implement a simple |
| 11 | // context sensitive alias analysis. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Chris Lattner | 1c8327b | 2005-03-17 20:33:27 +0000 | [diff] [blame] | 15 | #include "llvm/Constants.h" |
| 16 | #include "llvm/DerivedTypes.h" |
Misha Brukman | a975a9a | 2004-03-12 06:14:22 +0000 | [diff] [blame] | 17 | #include "llvm/Module.h" |
| 18 | #include "llvm/Analysis/AliasAnalysis.h" |
Jeff Cohen | 1d7b5de | 2005-01-09 20:42:52 +0000 | [diff] [blame] | 19 | #include "llvm/Analysis/Passes.h" |
Chris Lattner | 4dabb2c | 2004-07-07 06:32:21 +0000 | [diff] [blame] | 20 | #include "llvm/Analysis/DataStructure/DataStructure.h" |
| 21 | #include "llvm/Analysis/DataStructure/DSGraph.h" |
Chris Lattner | 9a92729 | 2003-11-12 23:11:14 +0000 | [diff] [blame] | 22 | using namespace llvm; |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 23 | |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 24 | namespace { |
Chris Lattner | b12914b | 2004-09-20 04:48:05 +0000 | [diff] [blame] | 25 | class DSAA : public ModulePass, public AliasAnalysis { |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 26 | TDDataStructures *TD; |
Misha Brukman | a975a9a | 2004-03-12 06:14:22 +0000 | [diff] [blame] | 27 | BUDataStructures *BU; |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 28 | |
| 29 | // These members are used to cache mod/ref information to make us return |
| 30 | // results faster, particularly for aa-eval. On the first request of |
| 31 | // mod/ref information for a particular call site, we compute and store the |
| 32 | // calculated nodemap for the call site. Any time DSA info is updated we |
| 33 | // free this information, and when we move onto a new call site, this |
| 34 | // information is also freed. |
| 35 | CallSite MapCS; |
| 36 | std::multimap<DSNode*, const DSNode*> CallerCalleeMap; |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 37 | public: |
| 38 | DSAA() : TD(0) {} |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 39 | ~DSAA() { |
| 40 | InvalidateCache(); |
| 41 | } |
| 42 | |
| 43 | void InvalidateCache() { |
| 44 | MapCS = CallSite(); |
| 45 | CallerCalleeMap.clear(); |
| 46 | } |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 47 | |
| 48 | //------------------------------------------------ |
| 49 | // Implement the Pass API |
| 50 | // |
| 51 | |
| 52 | // run - Build up the result graph, representing the pointer graph for the |
| 53 | // program. |
| 54 | // |
Chris Lattner | b12914b | 2004-09-20 04:48:05 +0000 | [diff] [blame] | 55 | bool runOnModule(Module &M) { |
Chris Lattner | a612afc | 2003-02-26 19:29:36 +0000 | [diff] [blame] | 56 | InitializeAliasAnalysis(this); |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 57 | TD = &getAnalysis<TDDataStructures>(); |
Misha Brukman | a975a9a | 2004-03-12 06:14:22 +0000 | [diff] [blame] | 58 | BU = &getAnalysis<BUDataStructures>(); |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 59 | return false; |
| 60 | } |
| 61 | |
| 62 | virtual void getAnalysisUsage(AnalysisUsage &AU) const { |
Chris Lattner | a612afc | 2003-02-26 19:29:36 +0000 | [diff] [blame] | 63 | AliasAnalysis::getAnalysisUsage(AU); |
Misha Brukman | a975a9a | 2004-03-12 06:14:22 +0000 | [diff] [blame] | 64 | AU.setPreservesAll(); // Does not transform code |
| 65 | AU.addRequiredTransitive<TDDataStructures>(); // Uses TD Datastructures |
| 66 | AU.addRequiredTransitive<BUDataStructures>(); // Uses BU Datastructures |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | //------------------------------------------------ |
| 70 | // Implement the AliasAnalysis API |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 71 | // |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 72 | |
Chris Lattner | a612afc | 2003-02-26 19:29:36 +0000 | [diff] [blame] | 73 | AliasResult alias(const Value *V1, unsigned V1Size, |
| 74 | const Value *V2, unsigned V2Size); |
Chris Lattner | 5c70dc0 | 2003-06-29 00:54:08 +0000 | [diff] [blame] | 75 | |
Chris Lattner | 484e302 | 2004-05-23 21:14:27 +0000 | [diff] [blame] | 76 | ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size); |
Reid Spencer | 4a7ebfa | 2004-12-07 08:11:24 +0000 | [diff] [blame] | 77 | ModRefResult getModRefInfo(CallSite CS1, CallSite CS2) { |
| 78 | return AliasAnalysis::getModRefInfo(CS1,CS2); |
| 79 | } |
Chris Lattner | 92e41d5 | 2004-01-30 22:20:55 +0000 | [diff] [blame] | 80 | |
Chris Lattner | 851b534 | 2005-01-24 20:00:14 +0000 | [diff] [blame] | 81 | virtual void deleteValue(Value *V) { |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 82 | InvalidateCache(); |
Chris Lattner | 851b534 | 2005-01-24 20:00:14 +0000 | [diff] [blame] | 83 | BU->deleteValue(V); |
| 84 | TD->deleteValue(V); |
| 85 | } |
| 86 | |
| 87 | virtual void copyValue(Value *From, Value *To) { |
| 88 | if (From == To) return; |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 89 | InvalidateCache(); |
Chris Lattner | 851b534 | 2005-01-24 20:00:14 +0000 | [diff] [blame] | 90 | BU->copyValue(From, To); |
| 91 | TD->copyValue(From, To); |
| 92 | } |
| 93 | |
Chris Lattner | 5c70dc0 | 2003-06-29 00:54:08 +0000 | [diff] [blame] | 94 | private: |
| 95 | DSGraph *getGraphForValue(const Value *V); |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | // Register the pass... |
| 99 | RegisterOpt<DSAA> X("ds-aa", "Data Structure Graph Based Alias Analysis"); |
| 100 | |
| 101 | // Register as an implementation of AliasAnalysis |
| 102 | RegisterAnalysisGroup<AliasAnalysis, DSAA> Y; |
| 103 | } |
| 104 | |
Jeff Cohen | 1d7b5de | 2005-01-09 20:42:52 +0000 | [diff] [blame] | 105 | ModulePass *llvm::createDSAAPass() { return new DSAA(); } |
| 106 | |
Chris Lattner | 5c70dc0 | 2003-06-29 00:54:08 +0000 | [diff] [blame] | 107 | // getGraphForValue - Return the DSGraph to use for queries about the specified |
| 108 | // value... |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 109 | // |
Chris Lattner | 5c70dc0 | 2003-06-29 00:54:08 +0000 | [diff] [blame] | 110 | DSGraph *DSAA::getGraphForValue(const Value *V) { |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 111 | if (const Instruction *I = dyn_cast<Instruction>(V)) |
Chris Lattner | 5c70dc0 | 2003-06-29 00:54:08 +0000 | [diff] [blame] | 112 | return &TD->getDSGraph(*I->getParent()->getParent()); |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 113 | else if (const Argument *A = dyn_cast<Argument>(V)) |
Chris Lattner | 5c70dc0 | 2003-06-29 00:54:08 +0000 | [diff] [blame] | 114 | return &TD->getDSGraph(*A->getParent()); |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 115 | else if (const BasicBlock *BB = dyn_cast<BasicBlock>(V)) |
Chris Lattner | 5c70dc0 | 2003-06-29 00:54:08 +0000 | [diff] [blame] | 116 | return &TD->getDSGraph(*BB->getParent()); |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 117 | return 0; |
| 118 | } |
| 119 | |
Chris Lattner | a612afc | 2003-02-26 19:29:36 +0000 | [diff] [blame] | 120 | AliasAnalysis::AliasResult DSAA::alias(const Value *V1, unsigned V1Size, |
| 121 | const Value *V2, unsigned V2Size) { |
Chris Lattner | bd92b73 | 2003-06-19 21:15:11 +0000 | [diff] [blame] | 122 | if (V1 == V2) return MustAlias; |
| 123 | |
Chris Lattner | 5c70dc0 | 2003-06-29 00:54:08 +0000 | [diff] [blame] | 124 | DSGraph *G1 = getGraphForValue(V1); |
| 125 | DSGraph *G2 = getGraphForValue(V2); |
| 126 | assert((!G1 || !G2 || G1 == G2) && "Alias query for 2 different functions?"); |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 127 | |
Chris Lattner | 5c70dc0 | 2003-06-29 00:54:08 +0000 | [diff] [blame] | 128 | // Get the graph to use... |
| 129 | DSGraph &G = *(G1 ? G1 : (G2 ? G2 : &TD->getGlobalsGraph())); |
Chris Lattner | bd92b73 | 2003-06-19 21:15:11 +0000 | [diff] [blame] | 130 | |
Chris Lattner | 5c70dc0 | 2003-06-29 00:54:08 +0000 | [diff] [blame] | 131 | const DSGraph::ScalarMapTy &GSM = G.getScalarMap(); |
| 132 | DSGraph::ScalarMapTy::const_iterator I = GSM.find((Value*)V1); |
Chris Lattner | bac7da8 | 2004-04-26 14:44:08 +0000 | [diff] [blame] | 133 | if (I == GSM.end()) return NoAlias; |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 134 | |
Chris Lattner | bac7da8 | 2004-04-26 14:44:08 +0000 | [diff] [blame] | 135 | DSGraph::ScalarMapTy::const_iterator J = GSM.find((Value*)V2); |
| 136 | if (J == GSM.end()) return NoAlias; |
| 137 | |
Chris Lattner | bac7da8 | 2004-04-26 14:44:08 +0000 | [diff] [blame] | 138 | DSNode *N1 = I->second.getNode(), *N2 = J->second.getNode(); |
| 139 | unsigned O1 = I->second.getOffset(), O2 = J->second.getOffset(); |
Chris Lattner | 511f60c | 2005-03-18 00:21:03 +0000 | [diff] [blame] | 140 | if (N1 == 0 || N2 == 0) |
Chris Lattner | 5f4c0a8 | 2005-03-27 00:02:33 +0000 | [diff] [blame] | 141 | // Can't tell whether anything aliases null. |
| 142 | return AliasAnalysis::alias(V1, V1Size, V2, V2Size); |
Chris Lattner | 93ab219 | 2005-03-27 21:57:09 +0000 | [diff] [blame] | 143 | |
| 144 | // We can only make a judgment if one of the nodes is complete. |
Chris Lattner | bac7da8 | 2004-04-26 14:44:08 +0000 | [diff] [blame] | 145 | if (N1->isComplete() || N2->isComplete()) { |
| 146 | if (N1 != N2) |
| 147 | return NoAlias; // Completely different nodes. |
Chris Lattner | bd92b73 | 2003-06-19 21:15:11 +0000 | [diff] [blame] | 148 | |
Chris Lattner | bac7da8 | 2004-04-26 14:44:08 +0000 | [diff] [blame] | 149 | // See if they point to different offsets... if so, we may be able to |
| 150 | // determine that they do not alias... |
| 151 | if (O1 != O2) { |
| 152 | if (O2 < O1) { // Ensure that O1 <= O2 |
| 153 | std::swap(V1, V2); |
| 154 | std::swap(O1, O2); |
| 155 | std::swap(V1Size, V2Size); |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 156 | } |
Chris Lattner | bac7da8 | 2004-04-26 14:44:08 +0000 | [diff] [blame] | 157 | |
Chris Lattner | 2f72f94 | 2005-03-23 01:47:19 +0000 | [diff] [blame] | 158 | if (O1+V1Size <= O2) |
| 159 | return NoAlias; |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 160 | } |
| 161 | } |
| 162 | |
| 163 | // FIXME: we could improve on this by checking the globals graph for aliased |
| 164 | // global queries... |
Chris Lattner | 484e302 | 2004-05-23 21:14:27 +0000 | [diff] [blame] | 165 | return AliasAnalysis::alias(V1, V1Size, V2, V2Size); |
Chris Lattner | 8105cfb | 2003-02-03 22:50:46 +0000 | [diff] [blame] | 166 | } |
Chris Lattner | 5c70dc0 | 2003-06-29 00:54:08 +0000 | [diff] [blame] | 167 | |
Misha Brukman | a975a9a | 2004-03-12 06:14:22 +0000 | [diff] [blame] | 168 | /// getModRefInfo - does a callsite modify or reference a value? |
| 169 | /// |
| 170 | AliasAnalysis::ModRefResult |
| 171 | DSAA::getModRefInfo(CallSite CS, Value *P, unsigned Size) { |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 172 | DSNode *N = 0; |
| 173 | // First step, check our cache. |
| 174 | if (CS.getInstruction() == MapCS.getInstruction()) { |
| 175 | { |
| 176 | const Function *Caller = CS.getInstruction()->getParent()->getParent(); |
| 177 | DSGraph &CallerTDGraph = TD->getDSGraph(*Caller); |
| 178 | |
| 179 | // Figure out which node in the TD graph this pointer corresponds to. |
| 180 | DSScalarMap &CallerSM = CallerTDGraph.getScalarMap(); |
| 181 | DSScalarMap::iterator NI = CallerSM.find(P); |
| 182 | if (NI == CallerSM.end()) { |
| 183 | InvalidateCache(); |
| 184 | return DSAA::getModRefInfo(CS, P, Size); |
| 185 | } |
| 186 | N = NI->second.getNode(); |
| 187 | } |
| 188 | |
| 189 | HaveMappingInfo: |
| 190 | assert(N && "Null pointer in scalar map??"); |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 191 | |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 192 | typedef std::multimap<DSNode*, const DSNode*>::iterator NodeMapIt; |
| 193 | std::pair<NodeMapIt, NodeMapIt> Range = CallerCalleeMap.equal_range(N); |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 194 | |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 195 | // Loop over all of the nodes in the callee that correspond to "N", keeping |
| 196 | // track of aggregate mod/ref info. |
| 197 | bool NeverReads = true, NeverWrites = true; |
| 198 | for (; Range.first != Range.second; ++Range.first) { |
| 199 | if (Range.first->second->isModified()) |
| 200 | NeverWrites = false; |
| 201 | if (Range.first->second->isRead()) |
| 202 | NeverReads = false; |
| 203 | if (NeverReads == false && NeverWrites == false) |
| 204 | return AliasAnalysis::getModRefInfo(CS, P, Size); |
| 205 | } |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 206 | |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 207 | ModRefResult Result = ModRef; |
| 208 | if (NeverWrites) // We proved it was not modified. |
| 209 | Result = ModRefResult(Result & ~Mod); |
| 210 | if (NeverReads) // We proved it was not read. |
| 211 | Result = ModRefResult(Result & ~Ref); |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 212 | |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 213 | return ModRefResult(Result & AliasAnalysis::getModRefInfo(CS, P, Size)); |
| 214 | } |
| 215 | |
| 216 | // Any cached info we have is for the wrong function. |
| 217 | InvalidateCache(); |
| 218 | |
Misha Brukman | a975a9a | 2004-03-12 06:14:22 +0000 | [diff] [blame] | 219 | Function *F = CS.getCalledFunction(); |
Chris Lattner | 50cb9b4 | 2005-03-17 20:16:58 +0000 | [diff] [blame] | 220 | |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 221 | if (!F) return AliasAnalysis::getModRefInfo(CS, P, Size); |
Misha Brukman | a975a9a | 2004-03-12 06:14:22 +0000 | [diff] [blame] | 222 | |
Chris Lattner | 7d671b8 | 2005-03-24 03:04:50 +0000 | [diff] [blame] | 223 | if (F->isExternal()) { |
| 224 | // If we are calling an external function, and if this global doesn't escape |
| 225 | // the portion of the program we have analyzed, we can draw conclusions |
| 226 | // based on whether the global escapes the program. |
| 227 | Function *Caller = CS.getInstruction()->getParent()->getParent(); |
| 228 | DSGraph *G = &TD->getDSGraph(*Caller); |
| 229 | DSScalarMap::iterator NI = G->getScalarMap().find(P); |
| 230 | if (NI == G->getScalarMap().end()) { |
| 231 | // If it wasn't in the local function graph, check the global graph. This |
| 232 | // can occur for globals who are locally reference but hoisted out to the |
| 233 | // globals graph despite that. |
| 234 | G = G->getGlobalsGraph(); |
| 235 | NI = G->getScalarMap().find(P); |
| 236 | if (NI == G->getScalarMap().end()) |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 237 | return AliasAnalysis::getModRefInfo(CS, P, Size); |
Chris Lattner | 7d671b8 | 2005-03-24 03:04:50 +0000 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | // If we found a node and it's complete, it cannot be passed out to the |
| 241 | // called function. |
| 242 | if (NI->second.getNode()->isComplete()) |
| 243 | return NoModRef; |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 244 | return AliasAnalysis::getModRefInfo(CS, P, Size); |
Chris Lattner | 7d671b8 | 2005-03-24 03:04:50 +0000 | [diff] [blame] | 245 | } |
| 246 | |
Chris Lattner | 511f60c | 2005-03-18 00:21:03 +0000 | [diff] [blame] | 247 | // Get the graphs for the callee and caller. Note that we want the BU graph |
| 248 | // for the callee because we don't want all caller's effects incorporated! |
| 249 | const Function *Caller = CS.getInstruction()->getParent()->getParent(); |
| 250 | DSGraph &CallerTDGraph = TD->getDSGraph(*Caller); |
| 251 | DSGraph &CalleeBUGraph = BU->getDSGraph(*F); |
Misha Brukman | a975a9a | 2004-03-12 06:14:22 +0000 | [diff] [blame] | 252 | |
Chris Lattner | 511f60c | 2005-03-18 00:21:03 +0000 | [diff] [blame] | 253 | // Figure out which node in the TD graph this pointer corresponds to. |
| 254 | DSScalarMap &CallerSM = CallerTDGraph.getScalarMap(); |
| 255 | DSScalarMap::iterator NI = CallerSM.find(P); |
| 256 | if (NI == CallerSM.end()) { |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 257 | ModRefResult Result = ModRef; |
Chris Lattner | db7436a | 2005-03-18 23:18:30 +0000 | [diff] [blame] | 258 | if (isa<ConstantPointerNull>(P) || isa<UndefValue>(P)) |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 259 | return NoModRef; // null is never modified :) |
Chris Lattner | 511f60c | 2005-03-18 00:21:03 +0000 | [diff] [blame] | 260 | else { |
Chris Lattner | 1c8327b | 2005-03-17 20:33:27 +0000 | [diff] [blame] | 261 | assert(isa<GlobalVariable>(P) && |
| 262 | cast<GlobalVariable>(P)->getType()->getElementType()->isFirstClassType() && |
| 263 | "This isn't a global that DSA inconsiderately dropped " |
| 264 | "from the graph?"); |
Chris Lattner | bc499de | 2005-03-26 22:47:03 +0000 | [diff] [blame] | 265 | |
| 266 | DSGraph &GG = *CallerTDGraph.getGlobalsGraph(); |
| 267 | DSScalarMap::iterator NI = GG.getScalarMap().find(P); |
| 268 | if (NI != GG.getScalarMap().end() && !NI->second.isNull()) { |
| 269 | // Otherwise, if the node is only M or R, return this. This can be |
| 270 | // useful for globals that should be marked const but are not. |
| 271 | DSNode *N = NI->second.getNode(); |
| 272 | if (!N->isModified()) |
| 273 | Result = (ModRefResult)(Result & ~Mod); |
| 274 | if (!N->isRead()) |
| 275 | Result = (ModRefResult)(Result & ~Ref); |
| 276 | } |
Chris Lattner | 511f60c | 2005-03-18 00:21:03 +0000 | [diff] [blame] | 277 | } |
Chris Lattner | 511f60c | 2005-03-18 00:21:03 +0000 | [diff] [blame] | 278 | |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 279 | if (Result == NoModRef) return Result; |
| 280 | return ModRefResult(Result & AliasAnalysis::getModRefInfo(CS, P, Size)); |
| 281 | } |
Chris Lattner | 511f60c | 2005-03-18 00:21:03 +0000 | [diff] [blame] | 282 | |
| 283 | // Compute the mapping from nodes in the callee graph to the nodes in the |
| 284 | // caller graph for this call site. |
| 285 | DSGraph::NodeMapTy CalleeCallerMap; |
| 286 | DSCallSite DSCS = CallerTDGraph.getDSCallSiteForCallSite(CS); |
| 287 | CallerTDGraph.computeCalleeCallerMapping(DSCS, *F, CalleeBUGraph, |
| 288 | CalleeCallerMap); |
| 289 | |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 290 | // Remember the mapping and the call site for future queries. |
| 291 | MapCS = CS; |
| 292 | |
| 293 | // Invert the mapping into CalleeCallerInvMap. |
Chris Lattner | 511f60c | 2005-03-18 00:21:03 +0000 | [diff] [blame] | 294 | for (DSGraph::NodeMapTy::iterator I = CalleeCallerMap.begin(), |
| 295 | E = CalleeCallerMap.end(); I != E; ++I) |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 296 | CallerCalleeMap.insert(std::make_pair(I->second.getNode(), I->first)); |
Chris Lattner | 511f60c | 2005-03-18 00:21:03 +0000 | [diff] [blame] | 297 | |
Chris Lattner | 1b9a2aa | 2005-03-26 23:29:03 +0000 | [diff] [blame] | 298 | N = NI->second.getNode(); |
| 299 | goto HaveMappingInfo; |
Misha Brukman | a975a9a | 2004-03-12 06:14:22 +0000 | [diff] [blame] | 300 | } |