Rearchitect var args support (making it actually work) [blocks: #4329]#4238
Rearchitect var args support (making it actually work) [blocks: #4329]#4238kroening merged 4 commits intodiffblue:developfrom
Conversation
|
Apologies for dragging in some many reviewers, that's just because I had to add the commits from #2068 to make things also work with the approach that Visual Studio uses for var args. Just the last three commits in this PR are actually new. |
33cbaa7 to
6c85222
Compare
allredj
left a comment
There was a problem hiding this comment.
✔️
Passed Diffblue compatibility checks (cbmc commit: ec8797e).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102429546
allredj
left a comment
There was a problem hiding this comment.
This PR failed Diffblue compatibility checks (cbmc commit: 93ba1d6).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102970072
Status will be re-evaluated on next push.
Common spurious failures:
-
the cbmc commit has disappeared in the mean time (e.g. in a force-push)
-
the author is not in the list of contributors (e.g. first-time contributors).
-
the compatibility was already broken by an earlier merge.
allredj
left a comment
There was a problem hiding this comment.
This PR failed Diffblue compatibility checks (cbmc commit: 7755806).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102970915
Status will be re-evaluated on next push.
Common spurious failures:
-
the cbmc commit has disappeared in the mean time (e.g. in a force-push)
-
the author is not in the list of contributors (e.g. first-time contributors).
-
the compatibility was already broken by an earlier merge.
617c92a to
00f323d
Compare
allredj
left a comment
There was a problem hiding this comment.
✔️
Passed Diffblue compatibility checks (cbmc commit: 00f323d).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/104075038
martin-cs
left a comment
There was a problem hiding this comment.
Very little touches my areas of responsibility but those bits ae fine.
allredj
left a comment
There was a problem hiding this comment.
✔️
Passed Diffblue compatibility checks (cbmc commit: 0c5f08c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105810019
allredj
left a comment
There was a problem hiding this comment.
This PR failed Diffblue compatibility checks (cbmc commit: dfd298a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/108813088
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.
| ^SIGNAL=0$ | ||
| ^VERIFICATION SUCCESSFUL$ | ||
| -- | ||
| ^warning: ignoring |
There was a problem hiding this comment.
Can you add a comment, say in the .desc file, how windows-preprocessed.i was produced?
There was a problem hiding this comment.
It was kind-of noted in the commit message, but I'll add a note in the .desc file as well!
| return convert_function(src, "gcc_builtin_va_arg_next"); | ||
| else if(statement == ID_va_start) | ||
| return convert_function(src, CPROVER_PREFIX "va_start"); | ||
| else |
There was a problem hiding this comment.
Does dumping still work with that change? Meaning do we still get a C program that gcc compiles?
There was a problem hiding this comment.
The changes (in this PR) to goto-instrument/goto_program2code.cpp take care of this.
| op_type.id() == ID_c_enum_tag || op_type.id() == ID_bv) | ||
| can_cast_type<bitvector_typet>(op_type) || op_type.id() == ID_c_enum || | ||
| op_type.id() == ID_c_enum_tag) | ||
| { |
There was a problem hiding this comment.
Note that ID_bool is not a bit vector type, i.e., this case is lost.
There was a problem hiding this comment.
Ah, thanks, fixed!
| fits_slot, | ||
| typecast_exprt::conditional_cast(parameter_expr, void_ptr_type), | ||
| typecast_exprt::conditional_cast( | ||
| address_of_exprt{parameter_expr}, void_ptr_type)}; |
There was a problem hiding this comment.
I am a bit surprised that this distinction needs to be a formula -- sure this isn't known at compile time?
There was a problem hiding this comment.
I believe that almost always the simplifier will be able to take care of this - but apart from that this used to construct an object that doesn't even exist at compile time, so I'm not really sure what you'd like me to do?
Even floating-point values are ok to just be re-interpreted as bit strings.
This will aid debugging as Visual Studio mostly just uses macros to implement the va_* functions.
We carry typedef names all the way now, there is no need for additional annotations to preserve the typedef name of va_list for dump-c.
Previously all the logic to access values of variable argument lists was put into our va_arg() implementation. This required guessing what the parameters could have been, and did not take into account the initial value passed to va_start. Now va_start triggers constructing an array of pointers to parameters, the first of which is the original argument to va_start. The va_list is then just a pointer to the first element of the array. va_arg just increments the pointer. goto_program conversion places a side_effect_exprt where va_start was, and goto-symex populates the array with the actual values applicable for a particular invocation of the function.
allredj
left a comment
There was a problem hiding this comment.
✔️
Passed Diffblue compatibility checks (cbmc commit: 18cbd69).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/111914482
Previously all the logic to access values of variable argument lists was put
into our va_arg() implementation. This required guessing what the parameters
could have been, and did not take into account the initial value passed to
va_start.
Now va_start triggers constructing an array of pointers to parameters, the first
of which is the original argument to va_start. The va_list is then just a
pointer to the first element of the array. va_arg just increments the pointer.
goto_program conversion places a side_effect_exprt where va_start was, and
goto-symex populates the array with the actual values applicable for a
particular invocation of the function.