From: Michael Kruse Date: Fri, 30 Sep 2016 15:29:43 +0000 (+0000) Subject: [Support] Call isl_*_free() only on non-null pointers. NFC. X-Git-Tag: llvmorg-4.0.0-rc1~8491 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=32312d0294c57a181ed7ba08431a644f11e1be6d;p=platform%2Fupstream%2Fllvm.git [Support] Call isl_*_free() only on non-null pointers. NFC. Add a non-NULL check before calling the free function into functions that are supposed to be inlined. First, this is a form of partial inlining of the free function, namely the nullptr test that free has to do. Secondly, and more importantly, it allows the compiler to remove the call to isl_*_free() when it knows that the object is nullptr, for instance because the last call is a take(). "Consuming" the last use of an ISL object using take() (instead of copy()) is a common pattern. llvm-svn: 282864 --- diff --git a/polly/include/polly/Support/GICHelper.h b/polly/include/polly/Support/GICHelper.h index b968ece..53c13e0 100644 --- a/polly/include/polly/Support/GICHelper.h +++ b/polly/include/polly/Support/GICHelper.h @@ -260,10 +260,14 @@ public: That.Obj = nullptr; } /* implicit */ IslPtr(NonowningIslPtr That) : IslPtr(That.copy(), true) {} - ~IslPtr() { Traits::free(Obj); } + ~IslPtr() { + if (Obj) + Traits::free(Obj); + } ThisTy &operator=(const ThisTy &That) { - Traits::free(this->Obj); + if (Obj) + Traits::free(Obj); this->Obj = Traits::copy(That.Obj); return *this; }