Skip to content

Support for LLLVM 15 16#1664

Merged
ccadar merged 26 commits intoklee:masterfrom
MartinNowack:llvm_15_16_support
Feb 8, 2024
Merged

Support for LLLVM 15 16#1664
ccadar merged 26 commits intoklee:masterfrom
MartinNowack:llvm_15_16_support

Conversation

@MartinNowack
Copy link
Contributor

@MartinNowack MartinNowack commented Oct 27, 2023

This PR adds support for LLVM 15 and 16.

There have been a multitude of required changes that are split into separate commits to simplify the whole process.

In a nutshell, we transitioned to support opaque pointers starting with LLVM 15 explicitly.
All the other commits handle additional moving parts in KLEE that had to be fixed.

Summary:

Checklist:

  • The PR addresses a single issue. If it can be divided into multiple independent PRs, please do so.
  • The PR is divided into a logical sequence of commits OR a single commit is sufficient.
  • There are no unnecessary commits (e.g. commits fixing issues in a previous commit in the same PR).
  • Each commit has a meaningful message documenting what it does.
  • All messages added to the codebase, all comments, as well as commit messages are spellchecked.
  • The code is commented OR not applicable/necessary.
  • The patch is formatted via clang-format OR not applicable (if explicitly overridden leave unchecked and explain).
  • There are test cases for the code you added or modified OR no such test cases are required.

@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Merging #1664 (5f7d0b2) into master (3ca81c2) will decrease coverage by 0.02%.
The diff coverage is 82.75%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1664      +/-   ##
==========================================
- Coverage   70.20%   70.18%   -0.02%     
==========================================
  Files         161      162       +1     
  Lines       19366    19397      +31     
  Branches     4626     4632       +6     
==========================================
+ Hits        13596    13614      +18     
- Misses       3730     3743      +13     
  Partials     2040     2040              
Files Coverage Δ
include/klee/Expr/Expr.h 84.76% <100.00%> (+0.05%) ⬆️
lib/Core/ExternalDispatcher.cpp 87.31% <ø> (ø)
lib/Core/GetElementPtrTypeIterator.h 93.93% <ø> (-1.62%) ⬇️
lib/Core/SpecialFunctionHandler.cpp 73.55% <ø> (ø)
lib/Module/FunctionAlias.cpp 90.56% <100.00%> (ø)
lib/Module/IntrinsicCleaner.cpp 92.97% <ø> (ø)
lib/Module/KModule.cpp 86.44% <100.00%> (+0.79%) ⬆️
lib/Module/LowerSwitch.cpp 77.77% <100.00%> (-1.39%) ⬇️
lib/Module/RaiseAsm.cpp 71.73% <ø> (ø)
tools/klee/main.cpp 64.72% <ø> (ø)
... and 3 more

... and 3 files with indirect coverage changes

@ccadar
Copy link
Contributor

ccadar commented Oct 30, 2023

@MartinNowack great to see this! I hope we'll see it ready soon!

However, we should first merge #1349 , #1380 and #1663.

@MartinNowack MartinNowack marked this pull request as ready for review October 30, 2023 16:09
@jirislaby
Copy link
Contributor

jirislaby commented Dec 14, 2023

I see (both with llvm 15 and 16 but not with llvm 14 -- even when the patches are applied):

[   35s] Failing Tests (3):
[   35s]     KLEE :: Feature/VarArgByVal.c
[   35s]     KLEE :: Runtime/POSIX/DirConsistency.c
[   35s]     KLEE :: Runtime/POSIX/SymFileConsistency.c

Full log

Copy link
Contributor

@ccadar ccadar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @MartinNowack.
Let's merge this as soon as #1380 , #1674 and #1663 are resolved.

@ccadar ccadar mentioned this pull request Jan 25, 2024
8 tasks
@ccadar
Copy link
Contributor

ccadar commented Jan 30, 2024

@MartinNowack I think this one is next! Do you want to rebase it to double-check that the FreeBSD checks pass, after the latest update? If you do, I spotted two tiny issues: "pointerws" is misspelled in commit message of 561fff8 and LLVM 17 seems to have been introduced prematurely in 5b13c51.

Copy link
Contributor

@danielschemmel danielschemmel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for all your hard work on this, @MartinNowack!

I have a few comments, most of which are just stylistic (uint64_t is actually called std::uint64_t and for most of the codebase we have an empty line between the includes and the rest of the code), but also one comment about the cmake changes that looks somewhat important.

I hope you can either just one-click apply or ignore the many small suggestions ;).

Comment on lines 63 to 65
make runtimes - j"$(nproc)" || make cxx || return 1
else
make cxx - j"$(nproc)" || make cxx || return 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like the original intent was to run a parallel make followed by a serial make of the same target. This change introduces two problems:

  1. There is a blank between the - and the j that should not be there
  2. it should probably also run make runtimes in the fallback position of the then-case

`-DLLVM_ENABLE_PROJECTS` does not include runtimes anymore,
instead a `-DLLVM_ENABLE_RUNTIMES` should be used in addition
`libc++` include headers are now split between platform dependent and
platform independent code.

Before, only include files for the platform independent code were
considered. Add support to automatically find platform dependent
includes as well.

Simplify the detection of libraries and paths.

Instead of pointing to the `v1` directory, pointing to the include
directory for `-DKLEE_LIBCXX_INCLUDE_PATH` is enough.

Update build script to support this as well.
…irectories

To support multiple include directories for c++ header files, use
`%libcxx_includes`. This string contains the `-I` compiler directive for
each include path as well.

Update test cases to use new directive.
Newer compilers use `-std=gnu17` as the default when compiling C code.
Fix all the test cases that violate this behaviour or explicitly request
older standards `-std=c89` where necessary.
Currently, we assume C++11 support being used to by the tested software.
This needs to change if newer C++ standards should be supported.
This automatically lifts old-style pointers to opaque pointers.
More recent versions use opaque pointers automatically and do not need
an explicit enabling.
`Intrinsic::flt_rounds` got removed
Handle like `memalign` for now.
Similar functionality needs to be added using a new pass manager
MartinNowack and others added 8 commits February 5, 2024 10:30
The optimiser generates different code and calls fwrite directly instead.
The wording changed slightly in newer versions.
Update the test case to support this.
They are not supported anymore for newer LLVM versions.
Co-authored-by: Daniel Schemmel <[email protected]>
(cherry picked from commit 5d9af02)
Co-authored-by: Daniel Schemmel <[email protected]>
(cherry picked from commit 5d61fb6)
Co-authored-by: Daniel Schemmel <[email protected]>
(cherry picked from commit 1ea1a75)
@MartinNowack
Copy link
Contributor Author

Thanks @ccadar and @danielschemmel for the review. I addressed most of the comments, I kept the lit's one LLVM 17. We will need it anyway soon 😃 So, this one is ready!

@ccadar
Copy link
Contributor

ccadar commented Feb 8, 2024

Thanks again, @MartinNowack , for the hard work of adding support for LLVM 15 & 16!

@ccadar ccadar merged commit 9336cd2 into klee:master Feb 8, 2024
@MartinNowack MartinNowack deleted the llvm_15_16_support branch February 8, 2024 14:21
@jirislaby
Copy link
Contributor

FWIW, current klee's HEAD -- 9336cd2 -- (still) compiles fine for me with LLVM 16. But I still see #1664 (comment):

[   36s]     KLEE :: Feature/VarArgByVal.c
[   36s]     KLEE :: Runtime/POSIX/DirConsistency.c
[   36s]     KLEE :: Runtime/POSIX/SymFileConsistency.c

@ccadar
Copy link
Contributor

ccadar commented Feb 9, 2024

Thanks, @jirislaby, I somehow thought that was resolved. Can you please open a new issue with more details? (what platform and configuration you are using, how the tests fail)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants