[PATCH] D20025: [PM] Make LowerAtomic a FunctionPass

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Fri May 6 10:32:59 PDT 2016


davide created this revision.
davide added reviewers: bogner, chandlerc.
davide added a subscriber: llvm-commits.

LowerAtomic happens to be a BasicBlockPass but the scope on which it operates is actually a function.
In general, I don't think BasicBlockPasses should exist at all and can be replaced by FunctionPass(es) which iterate over the set of BasicBlocks. If this looks fine, I'll port the pass to the new PM.

http://reviews.llvm.org/D20025

Files:
  lib/Transforms/Scalar/LowerAtomic.cpp

Index: lib/Transforms/Scalar/LowerAtomic.cpp
===================================================================
--- lib/Transforms/Scalar/LowerAtomic.cpp
+++ lib/Transforms/Scalar/LowerAtomic.cpp
@@ -110,16 +110,27 @@
 }
 
 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20025.56432.patch
Type: text/x-patch
Size: 1217 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160506/1821dbc3/attachment.bin>


More information about the llvm-commits mailing list