[PM] Make LowerAtomic a FunctionPass.

Differential Revision: http://reviews.llvm.org/D20025

llvm-svn: 269322
This commit is contained in:
Davide Italiano 2016-05-12 18:49:32 +00:00
parent 82e7df5a58
commit 851f879f32
1 changed files with 16 additions and 5 deletions

View File

@ -110,16 +110,27 @@ static bool LowerStoreInst(StoreInst *SI) {
}
namespace {
struct LowerAtomic : public BasicBlockPass {
struct LowerAtomic : public FunctionPass {
static char ID;
LowerAtomic() : BasicBlockPass(ID) {
LowerAtomic() : FunctionPass(ID) {
initializeLowerAtomicPass(*PassRegistry::getPassRegistry());
}
bool runOnBasicBlock(BasicBlock &BB) override {
if (skipBasicBlock(BB))
bool runOnFunction(Function &F) override {
if (skipFunction(F))
return false;
bool Changed = false;
for (BasicBlock::iterator DI = BB.begin(), DE = BB.end(); DI != DE; ) {
for (BasicBlock &BB: F) {
Changed |= runOnBasicBlock(BB);
}
return Changed;
}
private:
bool runOnBasicBlock(BasicBlock &BB) {
bool Changed = false;
for (BasicBlock::iterator DI = BB.begin(), DE = BB.end(); DI != DE;) {
Instruction *Inst = &*DI++;
if (FenceInst *FI = dyn_cast<FenceInst>(Inst))
Changed |= LowerFenceInst(FI);