This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Compiling for code coverage in CHERI LLVM

We have managed to build and run some code on the Morello platform, including our unit testing code, but so far haven't been able to enable the options for generating code coverage reports. Has anyone else tried to do this? It does work as expected on regular x86-64 platforms.

Here are the relevant parts of the CMakeLists.txt:

Fullscreen
1
2
3
add_executable(${PROJECT_NAME} logger.cpp logger_test.cpp)
target_compile_options(${PROJECT_NAME} PRIVATE -std=c++17 -g -O0 -Wall -Werror -Wextra -Wpedantic -ftest-coverage -fprofile-arcs -fprofile-instr-generate -fcoverage-mapping)
target_link_libraries(${PROJECT_NAME} gtest pthread gcov --coverage)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And here is the error output:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[ 33%] Building CXX object CMakeFiles/logger.dir/logger.cpp.o
FTy->getNumParams() = 4
FTy->getParamType(0) = i8*
Args[0]->getType() = i8 addrspace(200)*
FTy = void (i8*, i64, i32, i32)
Calling a function with a bad signature!
UNREACHABLE executed at /wrkdirs/usr/ports/devel/llvm-morello/work/llvm-project-0d2a3da490a43b0b78161f0040c3cbf60cb6e07d/llvm/lib/IR/Instructions.cpp:505!
#0 0x000000008aed7664 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local64/llvm-morello/bin/../lib/libLLVM-13git.so+0x1872664)
#1 0x000000008ae255f4 llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) (/usr/local64/llvm-morello/bin/../lib/libLLVM-13git.so+0x17c05f4)
#2 0x000000008b019650 llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, llvm::Twine const&) (/usr/local64/llvm-morello/bin/../lib/libLLVM-13git.so+0x19b4650)
#3 0x00000000871185e8 (/usr/local64/llvm-morello/bin/../lib/libclang-cpp.so.13git+0x231b5e8)
#4 0x000000008711823c (/usr/local64/llvm-morello/bin/../lib/libclang-cpp.so.13git+0x231b23c)
#5 0x00000000873756f8 clang::CodeGen::CodeGenPGO::emitCounterIncrement(clang::CodeGen::CGBuilderTy&, clang::Stmt const*, llvm::Value*) (/usr/local64/llvm-morello/bin/../lib/libclang-cpp.so.13git+0x25786f8)
#6 0x0000000087144f88 clang::CodeGen::CodeGenFunction::EmitConstructorBody(clang::CodeGen::FunctionArgList&) (/usr/local64/llvm-morello/bin/../lib/libclang-cpp.so.13git+0x2347f88)
#7 0x000000008732aa34 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/usr/local64/llvm-morello/bin/../lib/libclang-cpp.so.13git+0x252da34)
#8 0x00000000871235f0 clang::CodeGen::CodeGenModule::codegenCXXStructor(clang::GlobalDecl) (/usr/local64/llvm-morello/bin/../lib/libclang-cpp.so.13git+0x23265f0)
#9 0x00000000873c6eac (/usr/local64/llvm-morello/bin/../lib/libclang-cpp.so.13git+0x25c9eac)
#10 0x000000008733fc94 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/local64/llvm-morello/bin/../lib/libclang-cpp.so.13git+0x2542c94)
#11 0x00000000873436a0 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/usr/local64/llvm-morello/bin/../lib/libclang-cpp.so.13git+0x25466a0)
#12 0x00000000873c2348 (/usr/local64/llvm-morello/bin/../lib/libclang-cpp.so.13git+0x25c5348)
#13 0x00000000873e3ee8 (/usr/local64/llvm-morello/bin/../lib/libclang-cpp.so.13git+0x25e6ee8)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

My guess is that some relevant library simply isn't CHERI-ready, but I'm at the edge of my understanding here.

Thanks.

0