| Index: lib/Analysis/NaCl/PNaClSimplificationAnalyses.cpp
|
| diff --git a/lib/Analysis/NaCl/PNaClSimplificationAnalyses.cpp b/lib/Analysis/NaCl/PNaClSimplificationAnalyses.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9e7f9fda2c1ece6a9d567669a28f4ac21fda85e9
|
| --- /dev/null
|
| +++ b/lib/Analysis/NaCl/PNaClSimplificationAnalyses.cpp
|
| @@ -0,0 +1,56 @@
|
| +//===- llvm/Analysis/NaCl/SimplificationAnalyses.cpp ------------*- C++ -*-===//
|
| +//
|
| +// The LLVM Compiler Infrastructure
|
| +//
|
| +// This file is distributed under the University of Illinois Open Source
|
| +// License. See LICENSE.TXT for details.
|
| +//
|
| +//===----------------------------------------------------------------------===//
|
| +//
|
| +// This file houses implementations of the analysis passes used by the PNaCl IR
|
| +// simplification passes to remove extra passes over modules while progressive
|
| +// simplifying the IR, allowing them direct access to what each pass needs to
|
| +// expand.
|
| +//
|
| +//===----------------------------------------------------------------------===//
|
| +
|
| +#include "llvm/Analysis/NaCl/PNaClSimplificationAnalyses.h"
|
| +#include "llvm/IR/InstIterator.h"
|
| +
|
| +using namespace llvm;
|
| +
|
| +AtomicInfo::AtomicInfo(Function &F) {
|
| + for (Instruction &I : inst_range(F)) {
|
| + if (AtomicCmpXchgInst *AI = dyn_cast<AtomicCmpXchgInst>(&I)) {
|
| + CmpXchgs.push_back(AI);
|
| + } else if (LoadInst *LI = dyn_cast<LoadInst>(&I)) {
|
| + if (!LI->isSimple()) {
|
| + Loads.push_back(LI);
|
| + }
|
| + } else if (StoreInst *SI = dyn_cast<StoreInst>(&I)) {
|
| + if (!SI->isSimple()) {
|
| + Stores.push_back(SI);
|
| + }
|
| + } else if (AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(&I)) {
|
| + RMWs.push_back(RMWI);
|
| + } else if (FenceInst *FI = dyn_cast<FenceInst>(&I)) {
|
| + Fences.push_back(FI);
|
| + }
|
| + }
|
| +}
|
| +
|
| +char AtomicAnalysis::PassID;
|
| +
|
| +INITIALIZE_PASS(AtomicAnalysisWrapperPass, "pnacl-atomic-analysis",
|
| + "Find atomic instruction to expand", true, true)
|
| +char AtomicAnalysisWrapperPass::ID = 0;
|
| +
|
| +bool AtomicAnalysisWrapperPass::runOnFunction(Function &F) {
|
| + releaseMemory();
|
| + Info = std::move(AtomicInfo(F));
|
| + return false;
|
| +}
|
| +void AtomicAnalysisWrapperPass::releaseMemory() { Info.releaseMemory(); }
|
| +void AtomicAnalysisWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
| + AU.setPreservesAll();
|
| +}
|
|
|