llvm-project/polly/lib/External/isl/isl_test_cpp17-generic.cc
Michael Kruse 8dcc9b6355
[Polly] Update isl to isl-0.27 (#177776)
Fixes: #177527

Updated test cases:

* CodeGen/OpenMP/matmul-parallel.ll, ScheduleOptimizer/pattern-matching-based-opts.ll
  Before the update, ISL bailed out the dependency computation due to
  hitting the max operation limit. The commit
  https://repo.or.cz/isl.git/commit/4bdfe2567715c5d1a8287c07d8685eb3db281e32
  seems to have reduced the complexity needed of the dependency
  computation, thus now being able to recognize some loops as parallel.
  The tests were checking that the outer loop is not parallel, but some
  inner loops can be parallized, particularly the array packing loops.

 * DeLICM/reduction_looprotate_hoisted.ll
   changes in how isl generates expressions

 * ScheduleOptimizer/pattern-matching-based-opts_5.ll
   changes in how isl generates expressions, and AST node changes
2026-01-24 17:07:21 +01:00

69 lines
1.7 KiB
C++

/* A class that sets a boolean when an object of the class gets destroyed.
*/
struct S {
S(bool *freed) : freed(freed) {}
~S();
bool *freed;
};
/* S destructor.
*
* Set the boolean, a pointer to which was passed to the constructor.
*/
S::~S()
{
*freed = true;
}
/* Construct an isl::id with an S object attached that sets *freed
* when it gets destroyed.
*/
static isl::id construct_id(isl::ctx ctx, bool *freed)
{
auto s = std::make_shared<S>(freed);
isl::id id(ctx, "S", s);
return id;
}
/* Test id::try_user.
*
* In particular, check that the object attached to an identifier
* can be retrieved again, that trying to retrieve an object of the wrong type
* or trying to retrieve an object when no object was attached fails.
* Furthermore, check that the object attached to an identifier
* gets properly freed.
*/
static void test_try_user(isl::ctx ctx)
{
isl::id id(ctx, "test", 5);
isl::id id2(ctx, "test2");
auto maybe_int = id.try_user<int>();
auto maybe_s = id.try_user<std::shared_ptr<S>>();
auto maybe_int2 = id2.try_user<int>();
if (!maybe_int)
die("integer cannot be retrieved from isl::id");
if (*maybe_int != 5)
die("wrong integer retrieved from isl::id");
if (maybe_s)
die("structure unexpectedly retrieved from isl::id");
if (maybe_int2)
die("integer unexpectedly retrieved from isl::id");
bool freed = false;
{
isl::id id = construct_id(ctx, &freed);
if (freed)
die("data structure freed prematurely");
auto maybe_s = id.try_user<std::shared_ptr<S>>();
if (!maybe_s)
die("structure cannot be retrieved from isl::id");
if ((*maybe_s)->freed != &freed)
die("invalid structure retrieved from isl::id");
}
if (!freed)
die("data structure not freed");
}