Index: lib/Analysis/MemDepPrinter.cpp =================================================================== --- lib/Analysis/MemDepPrinter.cpp +++ lib/Analysis/MemDepPrinter.cpp @@ -27,14 +27,14 @@ enum DepType { Clobber = 0, Def, + NonLocal, NonFuncLocal, Unknown }; static const char *const DepTypeStr[]; - typedef PointerIntPair InstTypePair; - typedef std::pair Dep; + typedef std::tuple Dep; typedef SmallSetVector DepSet; typedef DenseMap DepSetMap; DepSetMap Deps; @@ -60,18 +60,21 @@ } private: - static InstTypePair getInstTypePair(MemDepResult dep) { + static Dep getDep(MemDepResult dep, const BasicBlock * bb) { if (dep.isClobber()) - return InstTypePair(dep.getInst(), Clobber); + return std::make_tuple(dep.getInst(), Clobber, bb); if (dep.isDef()) - return InstTypePair(dep.getInst(), Def); + return std::make_tuple(dep.getInst(), Def, bb); if (dep.isNonFuncLocal()) - return InstTypePair(dep.getInst(), NonFuncLocal); + return std::make_tuple(dep.getInst(), NonFuncLocal, bb); + if (dep.isNonLocal()) + return std::make_tuple(dep.getInst(), NonLocal, bb); assert(dep.isUnknown() && "unexpected dependence type"); - return InstTypePair(dep.getInst(), Unknown); + return std::make_tuple(dep.getInst(), Unknown, bb); } - static InstTypePair getInstTypePair(const Instruction* inst, DepType type) { - return InstTypePair(inst, type); + static Dep getDep( + const Instruction* inst, DepType type, const BasicBlock * bb) { + return std::make_tuple(inst, type, bb); } }; } @@ -88,7 +91,7 @@ } const char *const MemDepPrinter::DepTypeStr[] - = {"Clobber", "Def", "NonFuncLocal", "Unknown"}; + = {"Clobber", "Def", "NonLocal", "NonFuncLocal", "Unknown"}; bool MemDepPrinter::runOnFunction(Function &F) { this->F = &F; @@ -105,8 +108,7 @@ MemDepResult Res = MDA.getDependency(Inst); if (!Res.isNonLocal()) { - Deps[Inst].insert(std::make_pair(getInstTypePair(Res), - static_cast(nullptr))); + Deps[Inst].insert(getDep(Res, nullptr)); } else if (CallSite CS = cast(Inst)) { const MemoryDependenceAnalysis::NonLocalDepInfo &NLDI = MDA.getNonLocalCallDependency(CS); @@ -115,15 +117,14 @@ for (MemoryDependenceAnalysis::NonLocalDepInfo::const_iterator I = NLDI.begin(), E = NLDI.end(); I != E; ++I) { const MemDepResult &Res = I->getResult(); - InstDeps.insert(std::make_pair(getInstTypePair(Res), I->getBB())); + InstDeps.insert(getDep(Res, I->getBB())); } } else { SmallVector NLDI; if (LoadInst *LI = dyn_cast(Inst)) { if (!LI->isUnordered()) { // FIXME: Handle atomic/volatile loads. - Deps[Inst].insert(std::make_pair(getInstTypePair(nullptr, Unknown), - static_cast(nullptr))); + Deps[Inst].insert(getDep(nullptr, Unknown, nullptr)); continue; } AliasAnalysis::Location Loc = AA.getLocation(LI); @@ -131,8 +132,7 @@ } else if (StoreInst *SI = dyn_cast(Inst)) { if (!SI->isUnordered()) { // FIXME: Handle atomic/volatile stores. - Deps[Inst].insert(std::make_pair(getInstTypePair(nullptr, Unknown), - static_cast(nullptr))); + Deps[Inst].insert(getDep(nullptr, Unknown, nullptr)); continue; } AliasAnalysis::Location Loc = AA.getLocation(SI); @@ -148,7 +148,7 @@ for (SmallVectorImpl::const_iterator I = NLDI.begin(), E = NLDI.end(); I != E; ++I) { const MemDepResult &Res = I->getResult(); - InstDeps.insert(std::make_pair(getInstTypePair(Res), I->getBB())); + InstDeps.insert(getDep(Res, I->getBB())); } } } @@ -168,9 +168,9 @@ for (DepSet::const_iterator I = InstDeps.begin(), E = InstDeps.end(); I != E; ++I) { - const Instruction *DepInst = I->first.getPointer(); - DepType type = I->first.getInt(); - const BasicBlock *DepBB = I->second; + const Instruction *DepInst = std::get<0>(*I); + DepType type = std::get<1>(*I); + const BasicBlock *DepBB = std::get<2>(*I); OS << " "; OS << DepTypeStr[type];