Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] KValue base class #161

Merged
merged 4 commits into from
Dec 25, 2023
Merged

[feat] KValue base class #161

merged 4 commits into from
Dec 25, 2023

Conversation

S1eGa
Copy link
Collaborator

@S1eGa S1eGa commented Dec 12, 2023

No description provided.

@S1eGa S1eGa force-pushed the kvalue branch 3 times, most recently from 004b273 to c8e6394 Compare December 12, 2023 13:01
@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2023

Codecov Report

Merging #161 (26a5efe) into main (54b0620) will increase coverage by 0.04%.
The diff coverage is 66.66%.

❗ Current head 26a5efe differs from pull request most recent head 124aca9. Consider uploading reports for the commit 124aca9 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #161      +/-   ##
==========================================
+ Coverage   67.66%   67.70%   +0.04%     
==========================================
  Files         224      226       +2     
  Lines       31379    31491     +112     
  Branches     6888     6901      +13     
==========================================
+ Hits        21233    21322      +89     
- Misses       7536     7542       +6     
- Partials     2610     2627      +17     
Files Coverage Δ
include/klee/Core/Context.h 100.00% <100.00%> (ø)
include/klee/Expr/Expr.h 82.38% <ø> (ø)
include/klee/Expr/SymbolicSource.h 79.33% <100.00%> (ø)
include/klee/Module/KValue.h 100.00% <100.00%> (ø)
lib/Core/ExecutionState.cpp 74.46% <100.00%> (+0.18%) ⬆️
lib/Core/Executor.h 74.07% <ø> (ø)
lib/Core/ExternalDispatcher.cpp 82.55% <100.00%> (ø)
lib/Core/StatsTracker.cpp 79.92% <100.00%> (ø)
lib/Core/TargetManager.cpp 95.40% <100.00%> (+0.02%) ⬆️
lib/Expr/SourceBuilder.cpp 80.00% <100.00%> (+1.56%) ⬆️
... and 22 more

... and 3 files with indirect coverage changes

@S1eGa S1eGa force-pushed the kvalue branch 7 times, most recently from 894b8b8 to a260f75 Compare December 13, 2023 16:21
… llvm::* structures (KInstruction, KConstant, etc.)

[feat] Model unsized globals as objects of symbolic size.
@S1eGa S1eGa requested a review from misonijnik December 14, 2023 10:05
@S1eGa S1eGa marked this pull request as ready for review December 14, 2023 10:05

namespace klee {

struct KValue {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make KValue an abstract class.

@@ -102,8 +103,11 @@ int SymbolicSizeConstantAddressSource::internalCompare(
return size < ub.size ? -1 : 1;
}
if (allocSite != ub.allocSite) {
return allocSite->getGlobalIndex() < ub.allocSite->getGlobalIndex() ? -1
: 1;
if (allocSite->getKind() == ub.allocSite->getKind()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

KVlaue comparisons must be made within this class.

@@ -0,0 +1,30 @@
#include "klee/Support/CompilerWarning.h"
#include <klee/Module/KValue.h>
Copy link
Collaborator

Choose a reason for hiding this comment

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

< ... > -> " ... "

@@ -84,6 +89,10 @@ struct KBlock {

/// Block number in function
[[nodiscard]] uintptr_t getId() const;

static bool classof(const KValue *rhs) {
return rhs->getKind() == Kind::BLOCK ? classof(cast<KBlock>(rhs)) : false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ternary operator -> &&

@@ -40,6 +40,8 @@ class Context {

/// Returns width of the pointer in bits
Expr::Width getPointerWidth() const { return PointerWidth; }

Expr::Width getPointerWidthInBytes() const { return PointerWidth / CHAR_BIT; }
Copy link
Collaborator

@ocelaiwo ocelaiwo Dec 19, 2023

Choose a reason for hiding this comment

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

I don't think this is a good idea. A function taking an Expr::Width parameter will not know whether the width is in bits or bytes. There should be two types, Expr::BitWidth and Expr::ByteWidth with explicit conversions to each other.

@@ -771,7 +771,7 @@ class BitwuzlaIncNativeSolver {
Bitwuzla &getOrInit();

bool isConsistent() const {
klee_warning("Empty isConsistent() check");
// klee_warning("Empty isConsistent() check");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should attach a comment to this function that will describe what kind of check is to be expected here in the future (or remove this function altogether).

@@ -21,7 +22,7 @@ SourceBuilder::uninitialized(unsigned version, const KInstruction *allocSite) {
}

ref<SymbolicSource> SourceBuilder::symbolicSizeConstantAddress(
unsigned version, const KInstruction *allocSite, ref<Expr> size) {
unsigned version, const KValue *allocSite, ref<Expr> size) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need some way to restrict allocSite to those types of KValue that make sense as alloc sites. At least make a comment somewhere describing accepted derivatives or make a set of constructors accepting those derivatives only.

…s factory method for instructions and global variables. Added consistency check in bitwuzla.
@misonijnik misonijnik merged commit 40b2d74 into UnitTestBot:main Dec 25, 2023
24 checks passed
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