OLD | NEW |
(Empty) | |
| 1 //===- llvm/Analysis/NaCl/SimplificationAnalyses.cpp ------------*- C++ -*-===// |
| 2 // |
| 3 // The LLVM Compiler Infrastructure |
| 4 // |
| 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. |
| 7 // |
| 8 //===----------------------------------------------------------------------===// |
| 9 // |
| 10 // This file houses implementations of the analysis passes used by the PNaCl IR |
| 11 // simplification passes to remove extra passes over modules while progressive |
| 12 // simplifying the IR, allowing them direct access to what each pass needs to |
| 13 // expand. |
| 14 // |
| 15 //===----------------------------------------------------------------------===// |
| 16 |
| 17 #include "llvm/Analysis/NaCl/PNaClSimplificationAnalyses.h" |
| 18 #include "llvm/IR/InstIterator.h" |
| 19 |
| 20 using namespace llvm; |
| 21 |
| 22 AtomicInfo::AtomicInfo(Function &F) { |
| 23 for (Instruction &I : inst_range(F)) { |
| 24 if (AtomicCmpXchgInst *AI = dyn_cast<AtomicCmpXchgInst>(&I)) { |
| 25 CmpXchgs.push_back(AI); |
| 26 } else if (LoadInst *LI = dyn_cast<LoadInst>(&I)) { |
| 27 if (!LI->isSimple()) { |
| 28 Loads.push_back(LI); |
| 29 } |
| 30 } else if (StoreInst *SI = dyn_cast<StoreInst>(&I)) { |
| 31 if (!SI->isSimple()) { |
| 32 Stores.push_back(SI); |
| 33 } |
| 34 } else if (AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(&I)) { |
| 35 RMWs.push_back(RMWI); |
| 36 } else if (FenceInst *FI = dyn_cast<FenceInst>(&I)) { |
| 37 Fences.push_back(FI); |
| 38 } |
| 39 } |
| 40 } |
| 41 |
| 42 char AtomicAnalysis::PassID; |
| 43 |
| 44 INITIALIZE_PASS(AtomicAnalysisWrapperPass, "pnacl-atomic-analysis", |
| 45 "Find atomic instruction to expand", true, true) |
| 46 char AtomicAnalysisWrapperPass::ID = 0; |
| 47 |
| 48 bool AtomicAnalysisWrapperPass::runOnFunction(Function &F) { |
| 49 releaseMemory(); |
| 50 Info = std::move(AtomicInfo(F)); |
| 51 return false; |
| 52 } |
| 53 void AtomicAnalysisWrapperPass::releaseMemory() { Info.releaseMemory(); } |
| 54 void AtomicAnalysisWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const { |
| 55 AU.setPreservesAll(); |
| 56 } |
OLD | NEW |