Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I'm not familiar with how these tests usually work: is the intent just to see if they don't crash? IIUC there's no correctness check, right?
test/cfi/overwrite.cpp | ||
---|---|---|
18 ↗ | (On Diff #20224) | Could you explain this test? |
The purpose of this test suite is mostly to check that the enforcement mechanism works, i.e. that certain things (e.g. calls through classes of the wrong type, or calls through things that look like vtables but aren't) cause the program to crash. I'll add a few comments to each test case to explain what it is testing.
test/cfi/overwrite.cpp | ||
---|---|---|
18 ↗ | (On Diff #20224) | The test overwrites a's virtual function pointer with a pointer to fake_vtable and attempts to make a call through it. If the enforcement mechanism is working, the program will crash (checked via not --crash above). |
Lovely!
+samsonov for cmake code.
Questions:
can we make these tests run with -O0 and -O2 w/o adding extra RUN lines? what will happen with the tests if LTO is not supported?
test/cfi/anon-namespace.cpp | ||
---|---|---|
4 ↗ | (On Diff #20224) | Hm... I would actually like to have a way to validate that we have an expected crash, not some unrelated crash (e.g. due to miscompile). |
6 ↗ | (On Diff #20224) | Why does it require that now? Is that an LTO limitation? |
test/cfi/overwrite.cpp | ||
2 ↗ | (On Diff #20224) | I would like to run this test with and w/o CFI, so that w/o CFI we actually see foo() called. |
test/cfi/simple-fail.cpp | ||
2 ↗ | (On Diff #20224) | Same here and for all other --crash tests: I would like to also run these tests w/o CFI to see that they "work". |
test/cfi/simple-pass.cpp | ||
50 ↗ | (On Diff #20224) | we need to ensure that the calls are not devirtualized. |
- Add comments and a test for virtual inheritance
- Address Kostya's comments
test/cfi/anon-namespace.cpp | ||
---|---|---|
4 ↗ | (On Diff #20224) | Done |
6 ↗ | (On Diff #20224) | Added a comment explaining. |
test/cfi/overwrite.cpp | ||
2 ↗ | (On Diff #20224) | Done |
test/cfi/simple-fail.cpp | ||
2 ↗ | (On Diff #20224) | Done |
test/cfi/simple-pass.cpp | ||
50 ↗ | (On Diff #20224) | Done |
can we make these tests run with -O0 and -O2 w/o adding extra RUN lines?
Probably not, but I don't think it would make a difference at the moment. As far as I know, the optimization level chosen at compile time does not affect the level used at link time.
what will happen with the tests if LTO is not supported?
There is logic in lit.cfg to disable the tests if LTO is not supported.
The NCFI tests are checking that UB doesn't cause a crash. It would be nice for the test to point out exactly where the UB is so that if the test starts failing it's easy to figure out why.
Looks great.
Once Alexey LGTMs the cmake code you have my LGTM too.
Please, whenever you get any kind of question about the CFI add a test here that answers the question.
Of course, this patch depends on the other two.
The question about -O0 vs -O2 is more to Alexey.
I think we do have similar cmake magic somewhere, don't we?
It would be great to run all these tests with both -O0 and -O2
test/cfi/anon-namespace.cpp | ||
---|---|---|
43 ↗ | (On Diff #20246) | #endif // TU1 |
test/cfi/multiple-inheritance.cpp | ||
35 ↗ | (On Diff #20246) | If you use stderr you will not need fflush |
test/cfi/CMakeLists.txt | ||
---|---|---|
11 ↗ | (On Diff #20358) | Would this work if LLVM_BINUTILS_INCDIR is unavailable? |
test/cfi/lit.cfg | ||
8 ↗ | (On Diff #20358) | This should be set in test/lit.common.cfg |
9 ↗ | (On Diff #20358) | os.path.dirname(__file__) ? |
10 ↗ | (On Diff #20358) | You probably don't need test_exec_root here. |
11 ↗ | (On Diff #20358) | There is no such directory at the moment |
29 ↗ | (On Diff #20358) | We have config.clang for that |
32 ↗ | (On Diff #20358) | ditto |
38 ↗ | (On Diff #20358) | This should be handled by lit.common.cfg as well: we add llvm_tools_dir to PATH |
None of these tests have 32+ or 64+ vfunctions.
In a separate commit please add some larger tests to cover the case with more vfunctions.