[llvm-commits] [parallel] CVS: llvm/lib/Analysis/DataStructure/DataStructureAA.cpp
Misha Brukman
brukman at cs.uiuc.edu
Wed Mar 10 19:30:03 PST 2004
Changes in directory llvm/lib/Analysis/DataStructure:
DataStructureAA.cpp updated: 1.13.4.1 -> 1.13.4.2
---
Log message:
Implement getModRefInfo() for resolving aliasing between calls and values.
---
Diffs of the changes: (+37 -3)
Index: llvm/lib/Analysis/DataStructure/DataStructureAA.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.13.4.1 llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.13.4.2
--- llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.13.4.1 Mon Mar 1 17:58:12 2004
+++ llvm/lib/Analysis/DataStructure/DataStructureAA.cpp Wed Mar 10 19:29:34 2004
@@ -12,15 +12,16 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Module.h"
+#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/DataStructure.h"
#include "llvm/Analysis/DSGraph.h"
-#include "llvm/Analysis/AliasAnalysis.h"
-#include "llvm/Module.h"
using namespace llvm;
namespace {
class DSAA : public Pass, public AliasAnalysis {
TDDataStructures *TD;
+ BUDataStructures *BU;
public:
DSAA() : TD(0) {}
@@ -34,13 +35,15 @@
bool run(Module &M) {
InitializeAliasAnalysis(this);
TD = &getAnalysis<TDDataStructures>();
+ BU = &getAnalysis<BUDataStructures>();
return false;
}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AliasAnalysis::getAnalysisUsage(AU);
AU.setPreservesAll(); // Does not transform code...
- AU.addRequired<TDDataStructures>(); // Uses TD Datastructures
+ AU.addRequiredLive<TDDataStructures>(); // Uses TD Datastructures
+ AU.addRequiredLive<BUDataStructures>(); // Uses BU Datastructures
AU.addRequired<AliasAnalysis>(); // Chains to another AA impl...
}
@@ -56,6 +59,9 @@
bool pointsToConstantMemory(const Value *P) {
return getAnalysis<AliasAnalysis>().pointsToConstantMemory(P);
}
+
+ AliasAnalysis::ModRefResult
+ getModRefInfo(CallSite CS, Value *P, unsigned Size);
private:
DSGraph *getGraphForValue(const Value *V);
@@ -150,6 +156,34 @@
// FIXME: we could improve on this by checking the globals graph for aliased
// global queries...
return getAnalysis<AliasAnalysis>().alias(V1, V1Size, V2, V2Size);
+}
+
+/// getModRefInfo -
+///
+AliasAnalysis::ModRefResult
+DSAA::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
+ Function *F = CS.getCalledFunction();
+ if (!F) return pointsToConstantMemory(P) ? Ref : ModRef;
+ if (F->isExternal()) return ModRef;
+
+ // Clone the function TD graph, clearing off Mod/Ref flags
+ const Function *csParent = CS.getInstruction()->getParent()->getParent();
+ DSGraph TDGraph(TD->getDSGraph(*csParent));
+ TDGraph.maskNodeTypes(0);
+
+ // Insert the callee's BU graph into the TD graph
+ const DSGraph &BUGraph = BU->getDSGraph(*F);
+ TDGraph.mergeInGraph(TDGraph.getDSCallSiteForCallSite(CS),
+ *F, BUGraph, 0);
+
+ // Report the flags that have been added
+ const DSNodeHandle &DSH = TDGraph.getNodeForValue(P);
+ if (const DSNode *N = DSH.getNode())
+ if (N->isModified())
+ return N->isRead() ? ModRef : Mod;
+ else
+ return N->isRead() ? Ref : NoModRef;
+ return NoModRef;
}
More information about the llvm-commits
mailing list