From 183bb77aa8813765170c9870f35b11ee4bff4bfd Mon Sep 17 00:00:00 2001 From: David Bolvansky Date: Wed, 28 Aug 2019 15:04:48 +0000 Subject: [PATCH] [NFC] Added a comment to avoid possible confusion git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370217 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/InstCombine/InstCombineCalls.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp index c3be8c4e9a9..d304f98ceae 100644 --- a/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -4183,8 +4183,10 @@ static void annotateAnyAllocSite(CallBase &Call, const TargetLibraryInfo *TLI) { ConstantInt *Op1C = (Call.getNumArgOperands() == 1) ? nullptr : dyn_cast(Call.getOperand(1)); + // Bail out if the allocation size is zero. if ((Op0C && Op0C->isNullValue()) || (Op1C && Op1C->isNullValue())) return; + if (isMallocLikeFn(&Call, TLI) && Op0C) { Call.addAttribute(AttributeList::ReturnIndex, Attribute::getWithDereferenceableOrNullBytes( -- 2.40.0