Details
Diff Detail
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 | 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 | 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 | 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 | Why does it require that now? Is that an LTO limitation? | |
test/cfi/overwrite.cpp | ||
2 | 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 | 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 | we need to ensure that the calls are not devirtualized. |
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 | ||
---|---|---|
44 | #endif // TU1 | |
test/cfi/multiple-inheritance.cpp | ||
35 β | (On Diff #20246) | If you use stderr you will not need fflush |
test/cfi/CMakeLists.txt | ||
---|---|---|
12 | Would this work if LLVM_BINUTILS_INCDIR is unavailable? | |
test/cfi/lit.cfg | ||
9 | This should be set in test/lit.common.cfg | |
10 | os.path.dirname(__file__) ? | |
11 | You probably don't need test_exec_root here. | |
12 | There is no such directory at the moment | |
30 | We have config.clang for that | |
33 | ditto | |
39 | 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.
Would this work if LLVM_BINUTILS_INCDIR is unavailable?