[MCA][RegisterFile] Consistently update the PRF in the presence of multiple writes...
authorAndrea Di Biagio <andrea.dibiagio@sony.com>
Thu, 26 Aug 2021 17:57:59 +0000 (18:57 +0100)
committerAndrea Di Biagio <andrea.dibiagio@sony.com>
Thu, 26 Aug 2021 18:16:20 +0000 (19:16 +0100)
My last change to the RegisterFile (PR51495) has introduced a bug in the logic
that allocates physical registers in the PRF.

In some cases, this bug could have triggered a nasty unsigned wrap in the number
of allocated registers, thus resulting in mca being stuck forever in a loop of
PRF availability checks.

llvm/lib/MCA/HardwareUnits/RegisterFile.cpp

index 1c0f40d..474bf84 100644 (file)
@@ -294,7 +294,9 @@ void RegisterFile::addRegisterWrite(WriteRef Write,
     const WriteState *OtherWS = OtherWrite.getWriteState();
     if (OtherWS && OtherWrite.getSourceIndex() == Write.getSourceIndex()) {
       if (OtherWS->getLatency() > WS.getLatency()) {
-        // Conservatively keep the slowest write to RegID.
+        // Conservatively keep the slowest write on RegID.
+        if (ShouldAllocatePhysRegs)
+          allocatePhysRegs(RegisterMappings[RegID].second, UsedPhysRegs);
         return;
       }
     }