[llvm] r285988 - Only log the visit of a return instruction if we in fact found a return
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 3 23:59:50 PDT 2016
Author: chandlerc
Date: Fri Nov 4 01:59:50 2016
New Revision: 285988
URL: http://llvm.org/viewvc/llvm-project?rev=285988&view=rev
Log:
Only log the visit of a return instruction if we in fact found a return
instruction.
This avoids dereferencing null in the debug logging if the instruction
was not in fact a return instruction. This potential bug was found by
PVS-Studio.
This actually fixes the last of the "dereferenced a pointer before
checking it for null" reports in the recent PVS-Studio run. However,
there are quite a few reports of this nature that I did not do anything
to fix because they are pretty glaring false positives. They usually
took the form of quite clear correlated checks or a check made in
a separate function. I've even added asserts anywhere this correlation
wasn't pretty obvious and fundamental to the code.
Modified:
llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
Modified: llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp?rev=285988&r1=285987&r2=285988&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp (original)
+++ llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp Fri Nov 4 01:59:50 2016
@@ -2086,12 +2086,11 @@ void ObjCARCOpt::OptimizeReturns(Functio
SmallPtrSet<const BasicBlock *, 4> Visited;
for (BasicBlock &BB: F) {
ReturnInst *Ret = dyn_cast<ReturnInst>(&BB.back());
-
- DEBUG(dbgs() << "Visiting: " << *Ret << "\n");
-
if (!Ret)
continue;
+ DEBUG(dbgs() << "Visiting: " << *Ret << "\n");
+
const Value *Arg = GetRCIdentityRoot(Ret->getOperand(0));
// Look for an ``autorelease'' instruction that is a predecessor of Ret and
More information about the llvm-commits
mailing list