-
Notifications
You must be signed in to change notification settings - Fork 273
Rearchitect var args support (making it actually work) [blocks: #4329] #4238
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
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: ec8797e).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102429546
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 00f323d).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/104075038
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very little touches my areas of responsibility but those bits ae fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 0c5f08c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105810019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment, say in the .desc file, how windows-preprocessed.i was produced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was kind-of noted in the commit message, but I'll add a note in the .desc file as well!
else if(statement==ID_gcc_builtin_va_arg_next) | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes (in this PR) to goto-instrument/goto_program2code.cpp take care of this.
op_type.id() == ID_bool || op_type.id() == ID_c_enum || | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that ID_bool is not a bit vector type, i.e., this case is lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
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.