This is an archive of the discontinued LLVM Phabricator instance.

[Polly] Introduce unittests.
ClosedPublic

Authored by Meinersbur on Aug 24 2016, 5:44 AM.

Details

Summary

Add the infrastructure for unittests to Polly and two simple tests for conversion between isl_val and APInt.

Clang's unittest mechanism served as as a blueprint which then was adapted to Polly.

In addition, a build target check-polly-unittests is added to run only the unittests but not the regression tests.

Diff Detail

Event Timeline

Meinersbur updated this revision to Diff 69100.Aug 24 2016, 5:44 AM
Meinersbur retitled this revision from to [Polly] Introduce unittests..
Meinersbur updated this object.
Meinersbur added a project: Restricted Project.
Meinersbur added subscribers: pollydev, llvm-commits.

Currently testing whether out-of-tree builds and non-assert builds work.

grosser accepted this revision.Aug 24 2016, 5:54 AM
grosser edited edge metadata.

Very cool. I have been looking forward to this since a while!

CMakeLists.txt
208

Good idea to check formatting here as well.

unittests/Isl/IslTest.cpp
2

DeLICMTest.cpp - This seems to be a leftover?

28


22 ​ {
23 ​ APInt APNOne(32, -1, true);
24 ​ auto *IslNOne = isl_valFromAPInt(IslCtx, APNOne, false);

with 'false' in valFromAPInt might also be an interesting test case.

62

Very interesting observation. Do you have an idea why this is working today? Or does this indeed result in a bug that can be triggered externally?

This revision is now accepted and ready to land.Aug 24 2016, 5:54 AM
Meinersbur marked an inline comment as done.Aug 24 2016, 6:25 AM
Meinersbur added inline comments.
unittests/Isl/IslTest.cpp
28

I am not sure what the result even should be as the test was specifically designed to get negative one. Currently it returns '4294967295'. If this is the indented result, we should test

APInt APNOne(32, 4294967295, false);
auto *IslNOne = isl_valFromAPInt(IslCtx, APNOne, false);
EXPECT_EQ(isl_val_cmp_si(IslNOne , 4294967295), 0);

The APInt is equal to APInt(32, -1, true). The third argument only matters if first argument >64

62

I don't know.

grosser added inline comments.Aug 24 2016, 6:36 AM
unittests/Isl/IslTest.cpp
28

I wanted to test how negative one is converted if interpreted as unsigned in isl_valFromAPInt. 4294967295 is the answer I would expect. However, it is probably more readable if written as "1 << 32 - 1". As you noted APInt(32, 1 << 32 -1, false) should be equal to APInt(32, -1, true), so which of the two is used to construct the APInt probably does not matter.

If you agree such a test case is useful, I would it would be great if you could add it. Feel free to choose whichever constructor you prefer in APInt.

62

That's fair. We can work on this after the unit-test infrastructure is in place.

Meinersbur marked 3 inline comments as done.Aug 24 2016, 7:53 AM

Out-of-tree unit tests are not easy as it requires gtest from the LLVM source tree. Polly up to now only requires the LLVM_INSTALL_ROOT. llvm-config can be queried for the source dir, but then we need to compile gtest ourselves.

Clang has a different approach: It requires the source tree and broadly imports all cmake files such that it can use the LLVM functions to build the files.

Meinersbur marked an inline comment as done.
Meinersbur edited edge metadata.

Fix lit.site.cfg.in configuration; support out-of-tree indepdendent builds.

Nice. Thank you for fixing the out-of-tree build. It seems there is just a minor problem with unnecessary executable flags on some files left. Otherwise, this looks good.g

test/Unit/lit.cfg
2

It seems these files have accidentally the +x flag set.

Meinersbur marked an inline comment as done.Aug 24 2016, 1:04 PM
Meinersbur added inline comments.
test/Unit/lit.cfg
2

This is due to Lint running on a Windows filesystem which has no executable flags and therefore the flag is always set (otherwise one couldn't execute anything).

Git knows how to behave on Windows filesystems, so this won't be part of the commit.

This revision was automatically updated to reflect the committed changes.
Meinersbur marked an inline comment as done.