diff options
author | Tobias Grosser <tobias@grosser.es> | 2017-03-10 15:05:38 +0000 |
---|---|---|
committer | Tobias Grosser <tobias@grosser.es> | 2017-03-10 15:05:38 +0000 |
commit | 3e618c33fe991d6e848d928e932fda55c7f65500 (patch) | |
tree | 0415a4f6fdb0602c91da6abac0343ae3abdfc7fb /clang/lib/Format/Format.cpp | |
parent | 76377dcf99ddf628cdcd45833c839596e29e17f2 (diff) | |
download | bcm5719-llvm-3e618c33fe991d6e848d928e932fda55c7f65500.tar.gz bcm5719-llvm-3e618c33fe991d6e848d928e932fda55c7f65500.zip |
[DeadCodeElimination] Translate to C++ bindings
This pass is a small and self-contained example of a piece of code that was
written with the isl C interface. The diff of this change nicely shows how the
C++ bindings can improve the readability of the code by avoiding the long C
function names and by avoiding any need for memory management.
As you will see, no calls to isl_*_copy or isl_*_free are needed anymore.
Instead the C++ interface takes care of automatically managing the objects.
This may introduce internally additional copies, but due to the isl reference
counting, such copies are expected to be cheap. For performance critical
operations, we will later exploit move semantics to eliminate unnecessary
copies that have shown to be costly.
Below we give a set of examples that shows the benefit of the C++ interface vs.
the pure C interface.
Check properties
----------------
Before:
if (isl_aff_is_zero(aff) || isl_aff_is_one(aff))
return true;
After:
if (Aff.is_zero() || Aff.is_one())
return true;
Type conversion
---------------
Before:
isl_union_pw_multi_aff *UPMA = isl_union_pw_multi_aff_from_union_map(umap);
After:
isl::union_pw_multi_aff UPMA = UMap;
Type construction
-----------------
Before:
auto *Empty = isl_union_map_empty(space);
After:
auto Empty = isl::union_map::empty(Space);
Operations
----------
Before:
set = isl_union_set_intersect(set, set2);
After:
Set = Set.intersect(Set2);
The use of isl::boolean in return types also adds an increases the robustness
of Polly, as on conversion to true or false, we verify that no isl_bool_error
has been returned and assert in case an error was returned. Before this change
we would have just ignored the error and proceeded with (some) exection path.
Tags: #polly
Reviewed By: Meinersbur
Differential Revision: https://reviews.llvm.org/D30619
llvm-svn: 297466
Diffstat (limited to 'clang/lib/Format/Format.cpp')
0 files changed, 0 insertions, 0 deletions