[SelectionDAG] Don't create entries in ValueMap in ComputePHILiveOutRegInfo
authorCraig Topper <craig.topper@sifive.com>
Wed, 23 Mar 2022 16:28:46 +0000 (09:28 -0700)
committerCraig Topper <craig.topper@sifive.com>
Wed, 23 Mar 2022 16:52:07 +0000 (09:52 -0700)
Instead of using operator[], use DenseMap::find to prevent default
constructing an entry if it isn't already in the map.

Also simplify a condition to check for 0 instead of a virtual register.
I'm pretty sure we can only get 0 or a virtual register out of the value
map.

llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp

index b494551..e39ad73 100644 (file)
@@ -445,9 +445,14 @@ void FunctionLoweringInfo::ComputePHILiveOutRegInfo(const PHINode *PN) {
   IntVT = TLI->getTypeToTransformTo(PN->getContext(), IntVT);
   unsigned BitWidth = IntVT.getSizeInBits();
 
-  Register DestReg = ValueMap[PN];
-  if (!Register::isVirtualRegister(DestReg))
+  auto It = ValueMap.find(PN);
+  if (It == ValueMap.end())
     return;
+
+  Register DestReg = It->second;
+  if (DestReg == 0)
+    return
+  assert(Register::isVirtualRegister(DestReg) && "Expected a virtual reg");
   LiveOutRegInfo.grow(DestReg);
   LiveOutInfo &DestLOI = LiveOutRegInfo[DestReg];