X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAnalysis%2FMemDerefPrinter.cpp;h=36f1424c8cf96b014d34f87b4a3656b940a4827b;hb=ef80e8aad9371185a46120fdfa848526e9d103a0;hp=5903dc567042e271957abcca93011cfe86e4e716;hpb=1aa9710c60c872690d0d77c9d451a0e82dd7baeb;p=oota-llvm.git diff --git a/lib/Analysis/MemDerefPrinter.cpp b/lib/Analysis/MemDerefPrinter.cpp index 5903dc56704..36f1424c8cf 100644 --- a/lib/Analysis/MemDerefPrinter.cpp +++ b/lib/Analysis/MemDerefPrinter.cpp @@ -22,9 +22,10 @@ using namespace llvm; namespace { struct MemDerefPrinter : public FunctionPass { - SmallVector Vec; + SmallVector Deref; + SmallPtrSet DerefAndAligned; - static char ID; // Pass identifcation, replacement for typeid + static char ID; // Pass identification, replacement for typeid MemDerefPrinter() : FunctionPass(ID) { initializeMemDerefPrinterPass(*PassRegistry::getPassRegistry()); } @@ -34,7 +35,8 @@ namespace { bool runOnFunction(Function &F) override; void print(raw_ostream &OS, const Module * = nullptr) const override; void releaseMemory() override { - Vec.clear(); + Deref.clear(); + DerefAndAligned.clear(); } }; } @@ -51,11 +53,13 @@ FunctionPass *llvm::createMemDerefPrinter() { bool MemDerefPrinter::runOnFunction(Function &F) { const DataLayout &DL = F.getParent()->getDataLayout(); - for (auto &I: inst_range(F)) { + for (auto &I: instructions(F)) { if (LoadInst *LI = dyn_cast(&I)) { Value *PO = LI->getPointerOperand(); if (isDereferenceablePointer(PO, DL)) - Vec.push_back(PO); + Deref.push_back(PO); + if (isDereferenceableAndAlignedPointer(PO, LI->getAlignment(), DL)) + DerefAndAligned.insert(PO); } } return false; @@ -63,8 +67,12 @@ bool MemDerefPrinter::runOnFunction(Function &F) { void MemDerefPrinter::print(raw_ostream &OS, const Module *M) const { OS << "The following are dereferenceable:\n"; - for (auto &V: Vec) { + for (Value *V: Deref) { V->print(OS); + if (DerefAndAligned.count(V)) + OS << "\t(aligned)"; + else + OS << "\t(unaligned)"; OS << "\n\n"; } }