[llvm] 12bee2c - [GlobalOpt] Drop an incorrect check
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 17 01:11:41 PST 2022
Author: Nikita Popov
Date: 2022-01-17T10:10:56+01:00
New Revision: 12bee2c0542460db8080a8630b139953207846cf
URL: https://github.com/llvm/llvm-project/commit/12bee2c0542460db8080a8630b139953207846cf
DIFF: https://github.com/llvm/llvm-project/commit/12bee2c0542460db8080a8630b139953207846cf.diff
LOG: [GlobalOpt] Drop an incorrect check
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.
Added:
Modified:
llvm/lib/Transforms/IPO/GlobalOpt.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 1740a709a314..87ad4271877b 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -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
More information about the llvm-commits
mailing list