Index: lib/Analysis/CaptureTracking.cpp =================================================================== --- lib/Analysis/CaptureTracking.cpp +++ lib/Analysis/CaptureTracking.cpp @@ -331,25 +331,10 @@ AddUses(I); break; case Instruction::ICmp: { - // Don't count comparisons of a no-alias return value against null as - // captures. This allows us to ignore comparisons of malloc results - // with null, for example. - if (ConstantPointerNull *CPN = - dyn_cast(I->getOperand(1))) - if (CPN->getType()->getAddressSpace() == 0) - if (isNoAliasCall(V->stripPointerCasts())) - break; - // Comparison against value stored in global variable. Given the pointer - // does not escape, its value cannot be guessed and stored separately in a - // global variable. - unsigned OtherIndex = (I->getOperand(0) == V) ? 1 : 0; - auto *LI = dyn_cast(I->getOperand(OtherIndex)); - if (LI && isa(LI->getPointerOperand())) - break; - // Otherwise, be conservative. There are crazy ways to capture pointers - // using comparisons. - if (Tracker->captured(U)) - return; + // Pointers might be captured with some crazy pointer arithmetic, + // but calculating the pointers for these comparisons is undefined + // behavior. Therefore, we may assume that an icmp cannot capture a + // pointer. break; } default: