-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2149 from GaloisInc/T2148-match-LLVMValString
Match against `LLVMValString` in overrides (#2148)
- Loading branch information
Showing
7 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# The current checked-in test.bc was generated by: | ||
# Ubuntu clang version 14.0.0-1ubuntu1.1 | ||
# Target: x86_64-pc-linux-gnu | ||
# Thread model: posix | ||
# InstalledDir: /usr/bin | ||
# but neither the target nor the clang/llvm version is expected to be | ||
# significant. | ||
CC = clang | ||
CFLAGS = -g -O0 | ||
|
||
all: test.bc | ||
|
||
test.bc: test.c | ||
$(CC) $(CFLAGS) -c -emit-llvm $< -o $@ | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f test.bc |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "stdint.h" | ||
#include "stdbool.h" | ||
|
||
void foo(uint8_t xs[4]); | ||
|
||
void bar() { | ||
uint8_t xs[4] = {0,1,2,3}; | ||
for (int i = 0; i < 10; ++i) { | ||
foo(xs); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// A regression test that ensures that LLVM overrides will match successfully | ||
// when an argument is a string constant (#2148). | ||
|
||
let alloc_init ty v = do { | ||
p <- llvm_alloc ty; | ||
llvm_points_to p v; | ||
return p; | ||
}; | ||
|
||
let ptr_to_fresh n ty = do { | ||
x <- llvm_fresh_var n ty; | ||
p <- alloc_init ty (llvm_term x); | ||
return (x, p); | ||
}; | ||
|
||
let foo_spec1 = do { | ||
(x, p_x) <- ptr_to_fresh "xs" (llvm_array 4 (llvm_int 8)); | ||
|
||
llvm_execute_func [p_x]; | ||
|
||
llvm_points_to p_x (llvm_term x); | ||
}; | ||
|
||
// A slight variation of foo_spec1 that uses `llvm_fresh_expanded_val` instead | ||
// of `llvm_fresh_var`. This triggers a different code path in the LLVM override | ||
// matching logic. | ||
let foo_spec2 = do { | ||
let ty = llvm_array 4 (llvm_int 8); | ||
x <- llvm_fresh_expanded_val ty; | ||
p_x <- alloc_init ty x; | ||
|
||
llvm_execute_func [p_x]; | ||
|
||
llvm_points_to p_x x; | ||
}; | ||
|
||
let bar_spec = do { | ||
llvm_execute_func []; | ||
}; | ||
|
||
m <- llvm_load_module "test.bc"; | ||
|
||
foo_ov1 <- llvm_unsafe_assume_spec m "foo" foo_spec1; | ||
llvm_verify m "bar" [foo_ov1] true bar_spec z3; | ||
|
||
foo_ov2 <- llvm_unsafe_assume_spec m "foo" foo_spec2; | ||
llvm_verify m "bar" [foo_ov2] true bar_spec z3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
set -e | ||
|
||
$SAW test.saw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters