[PATCH] Introduce needsCleanup() for APFloat and APInt
Chandler Carruth
chandlerc at google.com
Wed May 29 00:14:45 PDT 2013
On Tue, May 28, 2013 at 7:04 PM, Shuxin Yang <shuxin.llvm at gmail.com> wrote:
> I just personally abhor the practice that promote private func (especially
> for the fundamental data structure)
> to public func without strong reasons. It is just my personal taste.
>
Just for the record, I think most of us agree with you.
I think the interesting difference of opinion is in what constitutes a
"strong reason". Personally, I find the use of pool allocators with APInt
an important use case, and others have demonstrated very serious
performance issues with unilaterally running destructors when deallocating
memory in some of these cases. Given these two concerns, exposing a way for
code to avoid running destructors when safe while not leaking memory, even
if that way is ugly, is a simple necessity of the situation we are in.
I would certainly love to find a better way to use pool allocation and
avoid undue cost of destructors that happen to be no-ops, all while
avoiding the further exposition of internal state in the public API, but I
have not yet found such a pattern. Until then, I think it is a reasonable
pragmatic solution -- avoid destructors where we can, ensure we don't leak
memory, and compromise the API in the least bad way while satisfying those
two goals.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130529/67188997/attachment.html>
More information about the llvm-commits
mailing list