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

Relax disjoint check for globals and fresh pointers. #1858

Merged
merged 3 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added intTests/test_llvm_global_fresh_pointer/test.bc
RyanGlScott marked this conversation as resolved.
Show resolved Hide resolved
Binary file not shown.
8 changes: 8 additions & 0 deletions intTests/test_llvm_global_fresh_pointer/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
int glb;

void foo(const int *x) {}

void bar(const int *x) {
foo(x);
}

29 changes: 29 additions & 0 deletions intTests/test_llvm_global_fresh_pointer/test.saw
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
enable_experimental;

m <- llvm_load_module "test.bc";

let foo_spec = do {
llvm_alloc_global "glb";
x_ptr <- llvm_fresh_pointer (llvm_int 32);
RyanGlScott marked this conversation as resolved.
Show resolved Hide resolved

llvm_execute_func [x_ptr];
};

foo_ov <- llvm_verify m "foo"
[]
false
foo_spec
(do {
print_goal;
w4_unint_z3 [];
});

llvm_verify m "bar"
[foo_ov]
false
foo_spec
(do {
print_goal;
w4_unint_z3 [];
});

4 changes: 4 additions & 0 deletions intTests/test_llvm_global_fresh_pointer/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set -e

$SAW test.saw

7 changes: 5 additions & 2 deletions src/SAWScript/Crucible/LLVM/Override.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,8 +1044,11 @@ enforceDisjointAllocGlobal ::
(LLVMAllocGlobal arch, LLVMPtr (Crucible.ArchWidth arch)) ->
OverrideMatcher (LLVM arch) md ()
enforceDisjointAllocGlobal sym loc
(LLVMAllocSpec _pmut _pty _palign psz pMd _pfresh _p_sym_init, p)
(LLVMAllocGlobal qloc (L.Symbol qname), q) =
(LLVMAllocSpec _pmut _pty _palign psz pMd pfresh _p_sym_init, p)
(LLVMAllocGlobal qloc (L.Symbol qname), q)
| pfresh =
pure () -- Fresh pointers need not be disjoint
| otherwise =
do let Crucible.LLVMPointer pblk _ = p
let Crucible.LLVMPointer qblk _ = q
c <- liftIO $ W4.notPred sym =<< W4.natEq sym pblk qblk
Expand Down