A single MachineInstr operand may now be both a def and a use.
authorVikram S. Adve <vadve@cs.uiuc.edu>
Mon, 8 Jul 2002 22:56:34 +0000 (22:56 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Mon, 8 Jul 2002 22:56:34 +0000 (22:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2825 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/LiveVar/BBLiveVar.cpp
lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
lib/Target/SparcV9/LiveVar/BBLiveVar.cpp
lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp

index efad03616b862822ccfe3b76ddec64ecfe57fc15..0b2979bf392ce055d0abdc492fdc1cf8c220f453 100644 (file)
@@ -7,6 +7,7 @@
 #include "BBLiveVar.h"
 #include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h"
 #include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/CodeGen/MachineCodeForBasicBlock.h"
 #include "llvm/Support/CFG.h"
 #include "Support/SetOperations.h"
 #include <iostream>
@@ -50,7 +51,7 @@ BBLiveVar::BBLiveVar(const BasicBlock &bb, unsigned id)
 
 void BBLiveVar::calcDefUseSets() {
   // get the iterator for machine instructions
-  const MachineCodeForBasicBlock &MIVec = BB.getMachineInstrVec();
+  const MachineCodeForBasicBlock &MIVec = MachineCodeForBasicBlock::get(&BB);
 
   // iterate over all the machine instructions in BB
   for (MachineCodeForBasicBlock::const_reverse_iterator MII = MIVec.rbegin(),
@@ -82,13 +83,13 @@ void BBLiveVar::calcDefUseSets() {
       if (isa<BasicBlock>(Op))
        continue;             // don't process labels
 
-      if (!OpI.isDef()) {   // add to Uses only if this operand is a use
-
+      if (!OpI.isDef() || OpI.isDefAndUse()) {
+                                // add to Uses only if this operand is a use
         //
         // *** WARNING: The following code for handling dummy PHI machine
         //     instructions is untested.  The previous code was broken and I
-        //     fixed it, but it turned out to be unused as long as Phi elimination
-        //     is performed during instruction selection.
+        //     fixed it, but it turned out to be unused as long as Phi
+        //     elimination is performed during instruction selection.
         // 
         // Put Phi operands in UseSet for the incoming edge, not node.
         // They must not "hide" later defs, and must be handled specially
@@ -118,7 +119,7 @@ void BBLiveVar::calcDefUseSets() {
       if (Op->getType() == Type::LabelTy)             // don't process labels
        continue;
 
-      if (!MI->implicitRefIsDefined(i))
+      if (!MI->implicitRefIsDefined(i) || MI->implicitRefIsDefinedAndUsed(i) )
        addUse(Op);
     }
   } // for all machine instructions
index 297b64a93c7e29660fbea5c9b2fce337b84e78a9..774bdc7cd7bcfb93124f08bfd74d33d06447a758 100644 (file)
@@ -8,6 +8,7 @@
 #include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h"
 #include "BBLiveVar.h"
 #include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/CodeGen/MachineCodeForBasicBlock.h"
 #include "llvm/Support/CFG.h"
 #include "Support/PostOrderIterator.h"
 #include "Support/SetOperations.h"
@@ -216,13 +217,15 @@ static void applyTranferFuncForMInst(ValueSet &LVS, const MachineInstr *MInst) {
   for (MachineInstr::const_val_op_iterator OpI = MInst->begin(),
          OpE = MInst->end(); OpI != OpE; ++OpI) {
     if (!isa<BasicBlock>(*OpI))      // don't process labels
-      if (!OpI.isDef())              // add only if this operand is a use
+      // add only if this operand is a use
+      if (!OpI.isDef() || OpI.isDefAndUse() )
         LVS.insert(*OpI);            // An operand is a use - so add to use set
   }
 
   // do for implicit operands as well
   for (unsigned i = 0, e = MInst->getNumImplicitRefs(); i != e; ++i)
-    if (!MInst->implicitRefIsDefined(i))
+    if (!MInst->implicitRefIsDefined(i) ||
+        MInst->implicitRefIsDefinedAndUsed(i))
       LVS.insert(MInst->getImplicitRef(i));
 }
 
@@ -233,7 +236,7 @@ static void applyTranferFuncForMInst(ValueSet &LVS, const MachineInstr *MInst) {
 //-----------------------------------------------------------------------------
 
 void FunctionLiveVarInfo::calcLiveVarSetsForBB(const BasicBlock *BB) {
-  const MachineCodeForBasicBlock &MIVec = BB->getMachineInstrVec();
+  const MachineCodeForBasicBlock &MIVec = MachineCodeForBasicBlock::get(BB);
 
   if (DEBUG_LV >= LV_DEBUG_Instr)
     std::cerr << "\n======For BB " << BB->getName()
index efad03616b862822ccfe3b76ddec64ecfe57fc15..0b2979bf392ce055d0abdc492fdc1cf8c220f453 100644 (file)
@@ -7,6 +7,7 @@
 #include "BBLiveVar.h"
 #include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h"
 #include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/CodeGen/MachineCodeForBasicBlock.h"
 #include "llvm/Support/CFG.h"
 #include "Support/SetOperations.h"
 #include <iostream>
@@ -50,7 +51,7 @@ BBLiveVar::BBLiveVar(const BasicBlock &bb, unsigned id)
 
 void BBLiveVar::calcDefUseSets() {
   // get the iterator for machine instructions
-  const MachineCodeForBasicBlock &MIVec = BB.getMachineInstrVec();
+  const MachineCodeForBasicBlock &MIVec = MachineCodeForBasicBlock::get(&BB);
 
   // iterate over all the machine instructions in BB
   for (MachineCodeForBasicBlock::const_reverse_iterator MII = MIVec.rbegin(),
@@ -82,13 +83,13 @@ void BBLiveVar::calcDefUseSets() {
       if (isa<BasicBlock>(Op))
        continue;             // don't process labels
 
-      if (!OpI.isDef()) {   // add to Uses only if this operand is a use
-
+      if (!OpI.isDef() || OpI.isDefAndUse()) {
+                                // add to Uses only if this operand is a use
         //
         // *** WARNING: The following code for handling dummy PHI machine
         //     instructions is untested.  The previous code was broken and I
-        //     fixed it, but it turned out to be unused as long as Phi elimination
-        //     is performed during instruction selection.
+        //     fixed it, but it turned out to be unused as long as Phi
+        //     elimination is performed during instruction selection.
         // 
         // Put Phi operands in UseSet for the incoming edge, not node.
         // They must not "hide" later defs, and must be handled specially
@@ -118,7 +119,7 @@ void BBLiveVar::calcDefUseSets() {
       if (Op->getType() == Type::LabelTy)             // don't process labels
        continue;
 
-      if (!MI->implicitRefIsDefined(i))
+      if (!MI->implicitRefIsDefined(i) || MI->implicitRefIsDefinedAndUsed(i) )
        addUse(Op);
     }
   } // for all machine instructions
index 297b64a93c7e29660fbea5c9b2fce337b84e78a9..774bdc7cd7bcfb93124f08bfd74d33d06447a758 100644 (file)
@@ -8,6 +8,7 @@
 #include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h"
 #include "BBLiveVar.h"
 #include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/CodeGen/MachineCodeForBasicBlock.h"
 #include "llvm/Support/CFG.h"
 #include "Support/PostOrderIterator.h"
 #include "Support/SetOperations.h"
@@ -216,13 +217,15 @@ static void applyTranferFuncForMInst(ValueSet &LVS, const MachineInstr *MInst) {
   for (MachineInstr::const_val_op_iterator OpI = MInst->begin(),
          OpE = MInst->end(); OpI != OpE; ++OpI) {
     if (!isa<BasicBlock>(*OpI))      // don't process labels
-      if (!OpI.isDef())              // add only if this operand is a use
+      // add only if this operand is a use
+      if (!OpI.isDef() || OpI.isDefAndUse() )
         LVS.insert(*OpI);            // An operand is a use - so add to use set
   }
 
   // do for implicit operands as well
   for (unsigned i = 0, e = MInst->getNumImplicitRefs(); i != e; ++i)
-    if (!MInst->implicitRefIsDefined(i))
+    if (!MInst->implicitRefIsDefined(i) ||
+        MInst->implicitRefIsDefinedAndUsed(i))
       LVS.insert(MInst->getImplicitRef(i));
 }
 
@@ -233,7 +236,7 @@ static void applyTranferFuncForMInst(ValueSet &LVS, const MachineInstr *MInst) {
 //-----------------------------------------------------------------------------
 
 void FunctionLiveVarInfo::calcLiveVarSetsForBB(const BasicBlock *BB) {
-  const MachineCodeForBasicBlock &MIVec = BB->getMachineInstrVec();
+  const MachineCodeForBasicBlock &MIVec = MachineCodeForBasicBlock::get(BB);
 
   if (DEBUG_LV >= LV_DEBUG_Instr)
     std::cerr << "\n======For BB " << BB->getName()