[llvm] r278923 - Fixing bug committed in rev. 278321

Marina Yatsina via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 17 04:40:21 PDT 2016


Author: myatsina
Date: Wed Aug 17 06:40:21 2016
New Revision: 278923

URL: http://llvm.org/viewvc/llvm-project?rev=278923&view=rev
Log:
Fixing bug committed in rev. 278321

In theory the indices of RC (and thus the index used for LiveRegs) may differ from the indices of OpRC.
Fixed the code to extract the correct RC index.
OpRC contains the first X consecutive elements of RC, and thus their indices are currently de facto the same, therefore a test cannot be added at this point.

Differential Revision: https://reviews.llvm.org/D23491


Modified:
    llvm/trunk/include/llvm/Target/TargetRegisterInfo.h
    llvm/trunk/lib/CodeGen/ExecutionDepsFix.cpp

Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=278923&r1=278922&r2=278923&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Wed Aug 17 06:40:21 2016
@@ -17,6 +17,7 @@
 #define LLVM_TARGET_TARGETREGISTERINFO_H
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/iterator_range.h"
 #include "llvm/CodeGen/MachineBasicBlock.h"
 #include "llvm/CodeGen/MachineValueType.h"
 #include "llvm/IR/CallingConv.h"
@@ -86,6 +87,11 @@ public:
 
   /// Return the number of registers in this class.
   unsigned getNumRegs() const { return MC->getNumRegs(); }
+  
+  iterator_range<SmallVectorImpl<MCPhysReg>::const_iterator>
+  getRegisters() const {
+    return make_range(MC->begin(), MC->end());
+  }
 
   /// Return the specified register in the class.
   unsigned getRegister(unsigned i) const {

Modified: llvm/trunk/lib/CodeGen/ExecutionDepsFix.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ExecutionDepsFix.cpp?rev=278923&r1=278922&r2=278923&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/ExecutionDepsFix.cpp (original)
+++ llvm/trunk/lib/CodeGen/ExecutionDepsFix.cpp Wed Aug 17 06:40:21 2016
@@ -509,12 +509,15 @@ void ExeDepsFix::pickBestRegisterForUnde
   // max clearance or clearance higher than Pref.
   unsigned MaxClearance = 0;
   unsigned MaxClearanceReg = OriginalReg;
-  for (unsigned rx = 0; rx < OpRC->getNumRegs(); ++rx) {
-    unsigned Clearance = CurInstr - LiveRegs[rx].Def;
+  for (auto Reg : OpRC->getRegisters()) {
+    assert(AliasMap[Reg].size() == 1 &&
+           "Reg is expected to be mapped to a single index");
+    int RCrx = *regIndices(Reg).begin();
+    unsigned Clearance = CurInstr - LiveRegs[RCrx].Def;
     if (Clearance <= MaxClearance)
       continue;
     MaxClearance = Clearance;
-    MaxClearanceReg = OpRC->getRegister(rx);
+    MaxClearanceReg = Reg;
 
     if (MaxClearance > Pref)
       break;




More information about the llvm-commits mailing list