[GlobalOpt] Drop an incorrect check
authorNikita Popov <npopov@redhat.com>
Mon, 17 Jan 2022 09:09:44 +0000 (10:09 +0100)
committerNikita Popov <npopov@redhat.com>
Mon, 17 Jan 2022 09:10:56 +0000 (10:10 +0100)
This was a last-minute addition to D117249, and of course I ended
up inverting the condition in a way that caused an uninitialized
memory read.

I've dropped it entirely, as I don't think we actually care whether
the size is zero or not here. The previous code wasn't checking
this either.

llvm/lib/Transforms/IPO/GlobalOpt.cpp

index 1740a70..87ad427 100644 (file)
@@ -1016,7 +1016,7 @@ static bool tryToOptimizeStoreOfMallocToGlobal(GlobalVariable *GV, CallInst *CI,
   assert(isMallocLikeFn(CI, TLI) && "Must be malloc-like call");
 
   uint64_t AllocSize;
-  if (!getObjectSize(CI, AllocSize, DL, TLI, ObjectSizeOpts()) && AllocSize > 0)
+  if (!getObjectSize(CI, AllocSize, DL, TLI, ObjectSizeOpts()))
     return false;
 
   // Restrict this transformation to only working on small allocations