This is an archive of the discontinued LLVM Phabricator instance.

[Polly] [DeadCodeElimination] Translate to C++ bindings
ClosedPublic

Authored by grosser on Mar 5 2017, 8:19 AM.

Details

Summary

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.isZero() || Aff.isOne())
  return true;

Type conversion

Before:

isl_union_pw_multi_aff *UPMA = isl_union_pw_multi_aff_from_union_map(umap);

After:

isl::UnionPwMultiAff UPMA = UMap;

Type construction

Before:

auto *Empty = isl_union_map_empty(space);

After:

auto Empty = isl::UnionMap::empty(Space);

Operations

Before:

set = isl_union_set_intersect(set, set2);

After:

Set = Set.intersect(Set2);

Diff Detail

Repository
rL LLVM

Event Timeline

grosser created this revision.Mar 5 2017, 8:19 AM
Meinersbur edited edge metadata.Mar 8 2017, 3:45 AM

Looks straightforward

lib/Transform/DeadCodeElimination.cpp
96 ↗(On Diff #90613)

Will the classes from ScopInfo.h (here: Scop::getSchedule()) be changed eventually as well?

I believe we should move all of Polly to the C++ bindings, but only _after_ they have been agreed on and upstreamed. Before, I would keep this local to the parts that are touched by the changes submitted.

Meinersbur accepted this revision.Mar 10 2017, 4:04 AM

LGTM

lib/Transform/DeadCodeElimination.cpp
141 ↗(On Diff #90613)

Note that there is a change in behavior here. Before it would enter the condition body on error, now it prints a warning (Which I prefer)

This revision is now accepted and ready to land.Mar 10 2017, 4:04 AM
This revision was automatically updated to reflect the committed changes.