-
Notifications
You must be signed in to change notification settings - Fork 269
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
Function pointer removal: create fall-back function call #6987
Function pointer removal: create fall-back function call #6987
Conversation
8c9b603
to
08c661f
Compare
The case where a function pointer matches none of the candidate functions now introduces a call to a new function. No implementation of this function is provided, leaving the choice to the user in case they choose to use goto-instrument's generate-function-body. As doing so requires updates to goto_functions by the caller, two unused API variants of remove_function_pointers were removed. Fixes: diffblue#6983
08c661f
to
36edcfe
Compare
Codecov Report
@@ Coverage Diff @@
## develop #6987 +/- ##
===========================================
+ Coverage 77.81% 77.83% +0.01%
===========================================
Files 1570 1569 -1
Lines 180682 180586 -96
===========================================
- Hits 140601 140552 -49
+ Misses 40081 40034 -47
Continue to review full report at Codecov.
|
Sorry to be That Person but can you split up the commit a bit? Maybe remove the unused APIs in a separate commit? The regression test clean ups might also be able to be separated? |
Hi, I was wondering what's the status of this change: @tautschnig? |
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'm a little unsure about the test cases. Something just feels a little bit off with the status changes. I'm not going to block this but it'd be really good if you could look at what is going on with them.
\[main.assertion.1\] line [0-9]+ assertion x == 1: SUCCESS | ||
^\*\*\*\* WARNING: no body for function main::fptr_call | ||
^\*\*\*\* WARNING: no body for function main::fptr_call\$0 | ||
\[f2.assertion.1\] line [0-9]+ assertion 0: FAILURE |
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.
Why is this now a failure? If I have read the right test case, there is no way f
can be set to f2
, so the assert in f2
cannot be reachable?
^\*\*\*\* WARNING: no body for function main::fptr_call | ||
^\*\*\*\* WARNING: no body for function main::fptr_call\$0 | ||
\[f2.assertion.1\] line [0-9]+ assertion 0: FAILURE | ||
\[main.assertion.1\] line [0-9]+ assertion x == 1: FAILURE |
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 also doesn't make sense, why does one of these fail but not the other?
CORE | ||
main.c | ||
|
||
^\*\*\*\* WARNING: no body for function indirect::fptr_call |
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 don't get why there is a warning in this context? There is only a single thing that fn_ptr
can point to?
@@ -4,9 +4,7 @@ typedef int (*other_function_type)(int n); | |||
|
|||
void foo(other_function_type other_function) | |||
{ | |||
// returning from the function call is unreachable -> the following assertion | |||
// should succeed |
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.
So there is a semantic change for cases where function pointers are invalid / NULL
/ otherwise not properly defined?
@@ -10,7 +10,7 @@ main.c | |||
^main::1::fun1 \(\) -> value-set-begin: ptr ->\(f\) :value-set-end | |||
^main::1::fun2_show \(\) -> value-set-begin: ptr ->\(f\), ptr ->\(g\) :value-set-end | |||
^main::1::fun3_show \(\) -> value-set-begin: ptr ->\(f\), ptr ->\(g\) :value-set-end | |||
^fun_global_show \(\) -> value-set-begin: ptr ->\(f\), ptr ->\(g\) :value-set-end | |||
^fun_global_show \(\) -> value-set-begin: TOP :value-set-end |
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.
Looking at the test case this is slightly concerning as {f, g}
is a legit and reasonable thing for it to be and it should only be set to TOP
if something really wrong is occurring. This looks like we might need to be a bit careful about how this PR interacts with the abstract interpreter.
@@ -5,6 +5,7 @@ test.c | |||
^SIGNAL=0$ | |||
^file test.c line 20 function main: replacing function pointer by 2 possible targets$ | |||
-- | |||
-- |
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.
Thanks!
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.
As mentioned out of band, I am unhappy with this PR as we are giving meaning to undefined behavior. Undefined behavior needs to stay that.
Closing as #7011 provided a solution without (potentially) giving meaning to undefined behaviour. |
The case where a function pointer matches none of the candidate
functions now introduces a call to a new function. No implementation of
this function is provided, leaving the choice to the user in case they
choose to use goto-instrument's generate-function-body.
As doing so requires updates to goto_functions by the caller, two unused
API variants of remove_function_pointers were removed.
Fixes: #6983