Skip to content

Commit 3b50883

Browse files
committed
Add a -max-sizet-in-bits option to our tools to control max size of address space
This allows one to shrink the size of counterexamples
1 parent 265524c commit 3b50883

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

llvm_util/cmd_args_def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ smt::solver_print_queries(opt_smt_verbose);
2020
smt::solver_tactic_verbose(opt_tactic_verbose);
2121
config::debug = opt_debug;
2222
config::max_offset_bits = opt_max_offset_in_bits;
23+
config::max_sizet_bits = opt_max_sizet_in_bits;
2324

2425
func_names.insert(opt_funcs.begin(), opt_funcs.end());
2526

llvm_util/cmd_args_list.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,11 @@ llvm::cl::opt<unsigned> opt_max_offset_in_bits(
141141
"offset computations exceed the maximum."),
142142
llvm::cl::cat(alive_cmdargs));
143143

144+
llvm::cl::opt<unsigned> opt_max_sizet_in_bits(
145+
LLVM_ARGS_PREFIX "max-sizet-in-bits", llvm::cl::init(64),
146+
llvm::cl::desc("Upper bound for the size of size_t. "
147+
"Note that this may impact correctness if the required "
148+
"address space size exceeds the specified limit."),
149+
llvm::cl::cat(alive_cmdargs));
150+
144151
}

tools/transform.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,7 @@ static void calculateAndInitConstants(Transform &t) {
10381038
// We need this assumption to support negative offsets.
10391039
bits_size_t = bit_width(max_alloc_size);
10401040
bits_size_t = min(max(bits_for_offset, bits_size_t), bits_program_pointer-1);
1041+
bits_size_t = min(bits_size_t, config::max_sizet_bits);
10411042

10421043
// +1 because the pointer after the object must be valid (can't overflow)
10431044
uint64_t loc_alloc_aligned_size

util/config.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ bool debug = false;
1919
unsigned src_unroll_cnt = 0;
2020
unsigned tgt_unroll_cnt = 0;
2121
unsigned max_offset_bits = 64;
22+
unsigned max_sizet_bits = 64;
2223

2324
ostream &dbg() {
2425
return *debug_os;

util/config.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern bool symexec_print_each_value;
1212

1313
extern bool skip_smt;
1414

15-
// don't dumo if empty
15+
// don't dump if empty
1616
extern std::string smt_benchmark_dir;
1717

1818
extern bool disable_poison_input;
@@ -30,6 +30,10 @@ extern unsigned tgt_unroll_cnt;
3030
// maximum.
3131
extern unsigned max_offset_bits;
3232

33+
// Max bits for size_t. This limits the internal address space, like max block
34+
// size and size of pointers (not to be confused with program pointer size).
35+
extern unsigned max_sizet_bits;
36+
3337
std::ostream &dbg();
3438
void set_debug(std::ostream &os);
3539

0 commit comments

Comments
 (0)