Bug fix: address used by indirect call instruction should also
authorVikram S. Adve <vadve@cs.uiuc.edu>
Sun, 31 Mar 2002 18:54:37 +0000 (18:54 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Sun, 31 Mar 2002 18:54:37 +0000 (18:54 +0000)
be marked as having a Call Interference, even though it may not
be live after the call.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2068 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp

index b6a8ae1f25b1b7017bf27ce49e48e0167e0982cf..49667e00795d678b85edbb1de48eab7fdbb86f5d 100644 (file)
@@ -211,20 +211,6 @@ void PhyRegAlloc::addInterference(const Value *Def,
 void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst, 
                                       const ValueSet *LVSetAft) {
 
-  // Now find the LR of the return value of the call
-  // We do this because, we look at the LV set *after* the instruction
-  // to determine, which LRs must be saved across calls. The return value
-  // of the call is live in this set - but it does not interfere with call
-  // (i.e., we can allocate a volatile register to the return value)
-  //
-  LiveRange *RetValLR = NULL;
-  const Value *RetVal = MRI.getCallInstRetVal( MInst );
-
-  if( RetVal ) {
-    RetValLR = LRI.getLiveRangeForValue( RetVal );
-    assert( RetValLR && "No LR for RetValue of call");
-  }
-
   if( DEBUG_RA)
     cerr << "\n For call inst: " << *MInst;
 
@@ -243,11 +229,10 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst,
       printSet(*LR);
     }
    
-
     // LR can be null if it is a const since a const 
     // doesn't have a dominating def - see Assumptions above
     //
-    if( LR && (LR != RetValLR) )   {  
+    if( LR )   {  
       LR->setCallInterference();
       if( DEBUG_RA) {
        cerr << "\n  ++Added call interf for LR: " ;
@@ -257,6 +242,26 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst,
 
   }
 
+  // Now find the LR of the return value of the call
+  // We do this because, we look at the LV set *after* the instruction
+  // to determine, which LRs must be saved across calls. The return value
+  // of the call is live in this set - but it does not interfere with call
+  // (i.e., we can allocate a volatile register to the return value)
+  //
+  if( const Value *RetVal = MRI.getCallInstRetVal( MInst )) {
+    LiveRange *RetValLR = LRI.getLiveRangeForValue( RetVal );
+    assert( RetValLR && "No LR for RetValue of call");
+    RetValLR->clearCallInterference();
+  }
+
+  // If the CALL is an indirect call, find the LR of the function pointer.
+  // That has a call interference because it conflicts with outgoing args.
+  if( const Value *AddrVal = MRI.getCallInstIndirectAddrVal( MInst )) {
+    LiveRange *AddrValLR = LRI.getLiveRangeForValue( AddrVal );
+    assert( AddrValLR && "No LR for indirect addr val of call");
+    AddrValLR->setCallInterference();
+  }
+
 }
 
 
index b6a8ae1f25b1b7017bf27ce49e48e0167e0982cf..49667e00795d678b85edbb1de48eab7fdbb86f5d 100644 (file)
@@ -211,20 +211,6 @@ void PhyRegAlloc::addInterference(const Value *Def,
 void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst, 
                                       const ValueSet *LVSetAft) {
 
-  // Now find the LR of the return value of the call
-  // We do this because, we look at the LV set *after* the instruction
-  // to determine, which LRs must be saved across calls. The return value
-  // of the call is live in this set - but it does not interfere with call
-  // (i.e., we can allocate a volatile register to the return value)
-  //
-  LiveRange *RetValLR = NULL;
-  const Value *RetVal = MRI.getCallInstRetVal( MInst );
-
-  if( RetVal ) {
-    RetValLR = LRI.getLiveRangeForValue( RetVal );
-    assert( RetValLR && "No LR for RetValue of call");
-  }
-
   if( DEBUG_RA)
     cerr << "\n For call inst: " << *MInst;
 
@@ -243,11 +229,10 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst,
       printSet(*LR);
     }
    
-
     // LR can be null if it is a const since a const 
     // doesn't have a dominating def - see Assumptions above
     //
-    if( LR && (LR != RetValLR) )   {  
+    if( LR )   {  
       LR->setCallInterference();
       if( DEBUG_RA) {
        cerr << "\n  ++Added call interf for LR: " ;
@@ -257,6 +242,26 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst,
 
   }
 
+  // Now find the LR of the return value of the call
+  // We do this because, we look at the LV set *after* the instruction
+  // to determine, which LRs must be saved across calls. The return value
+  // of the call is live in this set - but it does not interfere with call
+  // (i.e., we can allocate a volatile register to the return value)
+  //
+  if( const Value *RetVal = MRI.getCallInstRetVal( MInst )) {
+    LiveRange *RetValLR = LRI.getLiveRangeForValue( RetVal );
+    assert( RetValLR && "No LR for RetValue of call");
+    RetValLR->clearCallInterference();
+  }
+
+  // If the CALL is an indirect call, find the LR of the function pointer.
+  // That has a call interference because it conflicts with outgoing args.
+  if( const Value *AddrVal = MRI.getCallInstIndirectAddrVal( MInst )) {
+    LiveRange *AddrValLR = LRI.getLiveRangeForValue( AddrVal );
+    assert( AddrValLR && "No LR for indirect addr val of call");
+    AddrValLR->setCallInterference();
+  }
+
 }