[PATCH] D19080: allow SSAUpdater to be used for Swift

Bob Wilson via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 13 15:41:54 PDT 2016


bob.wilson created this revision.
bob.wilson added reviewers: joker.eph, dexonsmith.
bob.wilson added a subscriber: llvm-commits.
Herald added a subscriber: mcrosier.

The SSAUpdater is already implemented as a template so that we can reuse it for both IR-level and Machine-level updates. This simple change adds a new PhiItT typedef to the traits so that it can also be used for Swift's SIL representation, where phis are separate from other instructions.

http://reviews.llvm.org/D19080

Files:
  include/llvm/Transforms/Utils/SSAUpdaterImpl.h
  lib/CodeGen/MachineSSAUpdater.cpp
  lib/Transforms/Utils/SSAUpdater.cpp

Index: lib/Transforms/Utils/SSAUpdater.cpp
===================================================================
--- lib/Transforms/Utils/SSAUpdater.cpp
+++ lib/Transforms/Utils/SSAUpdater.cpp
@@ -216,6 +216,11 @@
   static BlkSucc_iterator BlkSucc_begin(BlkT *BB) { return succ_begin(BB); }
   static BlkSucc_iterator BlkSucc_end(BlkT *BB) { return succ_end(BB); }
 
+  /// Iterator over phis in a block.
+  typedef BlkT::iterator PhiItT;
+  static PhiItT PhiItT_begin(BlkT *BB) { return BB->begin(); }
+  static PhiItT PhiItT_end(BlkT *BB) { return BB->end(); }
+
   class PHI_iterator {
   private:
     PHINode *PHI;
Index: lib/CodeGen/MachineSSAUpdater.cpp
===================================================================
--- lib/CodeGen/MachineSSAUpdater.cpp
+++ lib/CodeGen/MachineSSAUpdater.cpp
@@ -246,6 +246,11 @@
   static BlkSucc_iterator BlkSucc_begin(BlkT *BB) { return BB->succ_begin(); }
   static BlkSucc_iterator BlkSucc_end(BlkT *BB) { return BB->succ_end(); }
 
+  /// Iterator over phis in a block.
+  typedef BlkT::iterator PhiItT;
+  static PhiItT PhiItT_begin(BlkT *BB) { return BB->begin(); }
+  static PhiItT PhiItT_end(BlkT *BB) { return BB->end(); }
+
   /// Iterator for PHI operands.
   class PHI_iterator {
   private:
Index: include/llvm/Transforms/Utils/SSAUpdaterImpl.h
===================================================================
--- include/llvm/Transforms/Utils/SSAUpdaterImpl.h
+++ include/llvm/Transforms/Utils/SSAUpdaterImpl.h
@@ -39,6 +39,7 @@
   typedef typename Traits::BlkT BlkT;
   typedef typename Traits::ValT ValT;
   typedef typename Traits::PhiT PhiT;
+  typedef typename Traits::PhiItT PhiItT;
 
   /// BBInfo - Per-basic block information used internally by SSAUpdaterImpl.
   /// The predecessors of each block are cached here since pred_iterator is
@@ -377,7 +378,7 @@
   /// FindExistingPHI - Look through the PHI nodes in a block to see if any of
   /// them match what is needed.
   void FindExistingPHI(BlkT *BB, BlockListTy *BlockList) {
-    for (typename BlkT::iterator BBI = BB->begin(), BBE = BB->end();
+    for (PhiItT BBI = Traits::PhiItT_begin(BB), BBE = Traits::PhiItT_end(BB);
          BBI != BBE; ++BBI) {
       PhiT *SomePHI = Traits::InstrIsPHI(&*BBI);
       if (!SomePHI)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19080.53632.patch
Type: text/x-patch
Size: 2256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160413/26cfe83e/attachment.bin>


More information about the llvm-commits mailing list