Skip to content

Commit fad48d8

Browse files
Relax disjoint check for globals and fresh pointers. (#1858)
* Relax disjoint check for globals and fresh pointers. * Add test. * Address comments.
1 parent a14d9a0 commit fad48d8

File tree

6 files changed

+58
-2
lines changed

6 files changed

+58
-2
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CLANG ?= clang
2+
CFLAGS = -g -frecord-command-line
3+
4+
all: test.bc
5+
6+
test.bc: test.c
7+
$(CLANG) -c -emit-llvm $(CFLAGS) $< -o $@
8+
9+
clean:
10+
rm -f test.bc
11+
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
int glb;
2+
3+
void foo(const int *x) {}
4+
5+
void bar(const int *x) {
6+
foo(x);
7+
}
8+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
enable_experimental;
2+
3+
m <- llvm_load_module "test.bc";
4+
5+
// test the fact that glb and x_ptr are allowed to alias each other.
6+
let foo_spec = do {
7+
llvm_alloc_global "glb";
8+
x_ptr <- llvm_fresh_pointer (llvm_int 32);
9+
10+
llvm_execute_func [x_ptr];
11+
};
12+
13+
foo_ov <- llvm_verify m "foo"
14+
[]
15+
false
16+
foo_spec
17+
(do {
18+
print_goal;
19+
w4_unint_z3 [];
20+
});
21+
22+
llvm_verify m "bar"
23+
[foo_ov]
24+
false
25+
foo_spec
26+
(do {
27+
print_goal;
28+
w4_unint_z3 [];
29+
});
30+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
set -e
2+
3+
$SAW test.saw
4+

src/SAWScript/Crucible/LLVM/Override.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,8 +1044,11 @@ enforceDisjointAllocGlobal ::
10441044
(LLVMAllocGlobal arch, LLVMPtr (Crucible.ArchWidth arch)) ->
10451045
OverrideMatcher (LLVM arch) md ()
10461046
enforceDisjointAllocGlobal sym loc
1047-
(LLVMAllocSpec _pmut _pty _palign psz pMd _pfresh _p_sym_init, p)
1048-
(LLVMAllocGlobal qloc (L.Symbol qname), q) =
1047+
(LLVMAllocSpec _pmut _pty _palign psz pMd pfresh _p_sym_init, p)
1048+
(LLVMAllocGlobal qloc (L.Symbol qname), q)
1049+
| pfresh =
1050+
pure () -- Fresh pointers need not be disjoint
1051+
| otherwise =
10491052
do let Crucible.LLVMPointer pblk _ = p
10501053
let Crucible.LLVMPointer qblk _ = q
10511054
c <- liftIO $ W4.notPred sym =<< W4.natEq sym pblk qblk

0 commit comments

Comments
 (0)