ManagerNoAddressOf.cpp
Go to the documentation of this file.00001
00018 #include "ManagerNoAddressOf.hpp"
00019
00020
00021 namespace OA {
00022 namespace Alias {
00023
00024 static bool debug = false;
00025
00028 OA_ptr<Alias::EquivSets> ManagerNoAddressOf::performAnalysis(ProcHandle proc)
00029 {
00030 if (debug) {
00031 std::cout << "In ManagerNoAddressOf::performAnalysis:" << std::endl;
00032 }
00033
00034
00035
00036 OA_ptr<EquivSets> retEquivSets; retEquivSets = new Alias::EquivSets(proc);
00037 int bigSetID = retEquivSets->makeEmptySet();
00038
00039
00040
00041
00042
00043
00044 if (debug) {
00045 std::cout << "\tequivSets so far = ";
00046 retEquivSets->dump(std::cout,mIR);
00047 }
00048
00049
00050 OA_ptr<OA::IRStmtIterator> sItPtr = mIR->getStmtIterator(proc);
00051 for ( ; sItPtr->isValid(); (*sItPtr)++) {
00052 OA::StmtHandle stmt = sItPtr->current();
00053
00054 if (debug) {
00055 std::cout << "\tstmt = ";
00056 mIR->dump(stmt,std::cout);
00057 }
00058
00059
00060 OA_ptr<MemRefHandleIterator> mrIterPtr = mIR->getAllMemRefs(stmt);
00061 for (; mrIterPtr->isValid(); (*mrIterPtr)++ )
00062 {
00063 MemRefHandle memref = mrIterPtr->current();
00064 if (debug) {
00065 std::cout << "\tmemref = ";
00066 mIR->dump(memref,std::cout);
00067 }
00068
00069
00070 OA_ptr<MemRefExprIterator> mreIterPtr
00071 = mIR->getMemRefExprIterator(memref);
00072
00073
00074 for (; mreIterPtr->isValid(); (*mreIterPtr)++) {
00075 OA_ptr<OA::MemRefExpr> mre = mreIterPtr->current();
00076 if (debug) {
00077 std::cout << "\tmre = ";
00078 mre->dump(std::cout,mIR);
00079 }
00080
00081
00082 int setId = retEquivSets->getEquivSetId(mre);
00083 if (debug) {
00084 std::cout << "\tsetId after getEquivSetId(mre) = " << setId
00085 << std::endl;
00086 }
00087
00088
00089 if (setId == EquivSets::SET_ID_NONE ) {
00090
00091 setId = bigSetID;
00092
00093
00094
00095
00096
00097
00098
00099
00100 OA_ptr<Location> loc
00101 = retEquivSets->trivialMREToLoc(mre);
00102 if (debug) {
00103 std::cout << "\tafter trivialMREToLoc, loc = ";
00104 loc->dump(std::cout,mIR);
00105 }
00106
00107 if (!loc.ptrEqual(NULL) && loc->isLocal()) {
00108 setId = retEquivSets->getEquivSetId(loc);
00109 if (debug) {
00110 std::cout << "\tsetId after getEquivSetId(loc) = "
00111 << setId << std::endl;
00112 }
00113
00114
00115
00116
00117
00118
00119 if (setId==EquivSets::SET_ID_NONE && loc->isaSubSet()) {
00120
00121 OA_ptr<Location> base = loc->getBaseLoc();
00122
00123
00124 setId = retEquivSets->getEquivSetId(base);
00125 assert(setId!=EquivSets::SET_ID_NONE);
00126
00127
00128 retEquivSets->addLocation(loc,setId);
00129
00130 } else if (setId==EquivSets::SET_ID_NONE) {
00131 setId = bigSetID;
00132 }
00133
00134 }
00135 }
00136
00137
00138
00139
00140
00141
00142
00143 if (setId!=bigSetID && mre->hasAddressTaken() )
00144 {
00145
00146 retEquivSets->mergeInto(setId,bigSetID);
00147
00148
00149
00150
00151 }
00152
00153 retEquivSets->mapMemRefToEquivSet(mre,setId);
00154
00155 retEquivSets->mapMemRefToMemRefExpr(memref,mre);
00156 retEquivSets->mapMemRefToEquivSet(memref,setId);
00157
00158 }
00159 }
00160 }
00161
00162 return retEquivSets;
00163
00164 }
00165
00166
00167 }
00168 }