[PATCH] D11491: [Polly] Move computations out of constructors
Michael Kruse
llvm at meinersbur.de
Fri Jul 24 12:44:33 PDT 2015
Meinersbur created this revision.
Meinersbur added a reviewer: grosser.
Meinersbur added subscribers: pollydev, llvm-commits.
Meinersbur added a project: Polly.
It is common practice to keep constructors lightweight. The reasons include:
- The vtable during the constructor's execution is set to the static type of the object, not to the vtable of the derived class. That is, method calls behave differently in constructors and ordinary methods. This way it is possible to call unimplemented methods of abstract classes, which usually results in a segmentation fault.
- If an exception is thrown in the constructor, the destructor is not called, potentially leaking memory.
- Code in constructors cannot be called in a regular way, e.g. from non-constructor methods of derived classes.
- Because it is common practice, people (including me) do not expect the constructor to do more than initializing data and skip them when looking for bugs.
Not all of these are applicable to LLVM (e.g. exceptions are disabled).
This patch refactors out the computational work in the constructors of Scop, ScopStmt and IslAst into regular init functions and introduces static create-functions as replacement. The constructor ScopArrayInfo also has calls, but it is small and does not call methods of its own class.
http://reviews.llvm.org/D11491
Files:
include/polly/ScopInfo.h
lib/Analysis/ScopInfo.cpp
lib/CodeGen/IslAst.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11491.30591.patch
Type: text/x-patch
Size: 12956 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150724/7ee0ea2d/attachment.bin>
More information about the llvm-commits
mailing list